Yes. Religion helps to hold communal groups together. As many others have already highlighted a number of the positive ways that religion can hold communal groups together such as shared belief systems and sense of identity and providing a framework for social interaction, I’d like to highlight the dark side of possible in communal groups including and perhaps especially in religion:
Religion can be exclusionary. Religion can be used to exclude not only individuals but also whole groups of people based on any number of arbitrary critera. Not sharing the same beliefs, values and behaviors is a common reason for exclusion. It can be as important or in many cases unfortunately MORE important to exclude; to “not be like those folks over there” and sure to not invite them in in fear of them tainting their own community as if those on the outside were a medical contagion.
Another dark reason for community is guilt. If certain expecations are set up for you to follow and you do not follow them, you can feel a sense of guilt, particularly if you were raised to. In the Roman Catholic church for example, attending mass on a regular basis is important and when one does not, guilt is a common effect – an instructed guilt. So this guilt can help form a sense of community among believers as they all share the same guilt.
Fear of punishment is another common way to bind that isn’t pleasant. Fear of hell can motivate parents to try to keep their kids from certain behaviors – both for themselves and for their children – and this can extend to the entire church body with this common fear as a common binding force.