If you investigate the material basis of religious belief, you immediately confront a phenomenon that operates on many different levels. In particular circumstances and particular settings a faith may function as a guide to morality, or an aesthetic, or a social network, or a collection of cultural practices, or a political identity, or a historical tradition, or some combination of any or all of those things.
You don’t have to be a believer to see that religion genuinely offers something to its adherents (often when nothing else is available) and that what it provides is neither inconsequential nor silly.
— Jeff Sparrow, The Guardian, We can save atheism from the New Atheists like Richard Dawkins and Sam Harris, November 29, 2015
Religion has and does offer some positive aspects to humans. It allows rituals in important times (births, deaths, weddings, etc) that being a community together for support, celebration, etc. Most religions offer meditation practices that scientists have shown to be beneficial for the human brain (prayer and meditation show up on brain scans as very similar). It used to offer guides to moral behaviors, stories to explain natural phenomena that pre scientific people couldn’t understand, and it offered a cultural identity of “who we are”. We humans are in a weird era where a lot of questions (but not all) have been answered by science, but we still want to understand who we are and have a community. We haven’t developed enough secular replacements for religious superstitious methods to accomplish the other aspects humans crave.