I'm almost hesitant to post here, as I suspect anything not overtly critical of religion is likely to be taken as "fighting words". I'm not trying to criticize or lionize anyone's worldview. But understanding the function of religion in society is one of the oldest questions in the social sciences, and we do know a fair amount about this as a result. Some common social features of religion that are often discussed include:
1. Cohesion
Religion helps to organize society, promote a unified group identity, and delineate between insiders and outsiders
2. Explanation
It also helps to explain things that would otherwise remain inexplicable, both unexplained material phenomenon and deeper questions, like "why am I here? What is the best way to live?" etc
3. Education
Religion often has a role in instruction, especially moral instruction, and helps to pass down cultural values that might otherwise be lost
4. Euphoria
Religious ritual provides feelings of awe, excitement, relief, enlightenment, etc. These experiences are often transformative, leading to changes in personality or motivation, and tend to cement cultural and moral values in the minds of participants, while motivating further action.
5. Revitalization
Rituals also reinforce and reinvigorate the structures and values of society, and its subsets, such as family bonds and so forth. Most public holidays are good examples of this function in action.
6. Ecology
Since the 1970s, there's been a growing awareness of the role that religion has played historically in mediating the contact between human groups and their environment, by adding critical moral value to decisions that are otherwise decided through self-interest. This insight led to the "Deep Ecology" movement, which attempted with varying degrees of success to reproduce the effect artificially.
7. Discipline
Religions provide a paradigm for moral behavior, a watchful community to enforce it, and promise both natural and supernatural punishments for perceived breaches of conduct
8. Support
Again, especially historically, religious hierarchies have been important agents of redistribution, taking in contributions of money and resources, and redistributing on the basis of need. The opening of religious buildings for community use or in times of disaster also qualifies. There is also individual support in terms of emotional counseling, spiritual guidance, and material assistance in times of trouble.
None of these things can
only be done by religion, but religion and other institutions similar to it (economic "theories", nationalist cults) are more efficient at accomplishing these goals, as they present people with a single, cohesive, and compelling worldview that accomplishes all of them at once, as opposed to say a government agency trying to tackle each goal individually and without the automatic buy-in from citizens that comes with an enculturated ideology.