I think religions are coded rules for living, coupled with promises and threats to compel people to live that way. They helped build trust and consistent behaviors and expectations within tribes and regions, which allowed the people to cooperate without a bureaucratic state. Thus religion was a very useful invention for early mankind.
In an era before strong central governments and mass communications and printing presses, religion was also a way to pass along history and moral lessons learned through hard experience, rather than having to re-learn those rules every generation. It codified the expected behavior of a tribe, and it created a punishing/rewarding entity that would compel that behavior.
The religions that succeeded were the ones that had rules that led to well functioning societies. So the Aztecs and the followers of Baal are no longer with us in large numbers, but Christians are, because the behavioral rules inherent in Christianity actually work pretty well. Honor your parents, don’t steal, don’t cheat on your wife or make yourself miserable lusting after things other people have that you don’t. Hard work is a good idea, as is treating other people as you’d want to be treated. Hot damn, pretty good rules.
Christianity and other modern mainstream religions are merely examples of evolutionary social change. The religions that adapted and changed with the times survived. The ones that didn’t died out or became fringe sects.
It can be argued that Christianity is an evolutionary offspring of Judaism, which has strict laws and is restricted to a single group of people. Christianity was a mutation that allowed for different behaviors, and applied them to everyone and not just Jews. The invention of a savior who would forgive you even if you screwed up so long as you promised to get back on the straight and narrow was brilliant in that it added a certain amount of breathing room that allowed people to stay with the faith as they got wealthier and more modern and had more conflicts with religious dogma, and it allowed for people to remain in the faith even when they failed in keeping up with all the rules.
There were many such evolutionary mutations - see the Gnostic gospels and the Apocrypha for different attempts to modify the faith that just didn’t work out. Christianity itself almost certainly evolved from earlier proto-religions and mythical stories such as the Epic of Gilgamesh.
The process continues today. There are numerous sects of Christianity, and they compete with each other for mind share. Some of them have radically different views of the Christian faith. Some are barely recognizable as a religion, as they’ve dumped most of the supernatural elements or assigned them as metaphors and see the Bible mainly as a good book for guiding your behavior. Others are fundamentalist and attract people with a desire to maintain a strict, controlled life perhaps.
All these sects are competing in a Darwinian fashion. The ones least compatible with human flourishing eventually get abandoned or die out from attrition. For example, imagine a religion which says thou shalt only have one child, or that you must sacrifice your first born to the Volcano God. That religion is not going to out-compete one that says go forth and be fruitful and multiply.
The ones that survived to the modern age are the ones that are vague enough in their claims about the real world that many people can comfortably hold them in a scientific age if they don’t think too hard about it.
Right up until present day, I think religion still serves as a trust boundary which enables small groups of people to function together better. This is why religion has remained strong in small and distant communities. The ritual of going to Church brings everyone together where they become known to each other. The promises they make during sermons and their expressions of faith and belief assure the people around them that they are just like them, which enables them to make deals and share labor and ideas without contracts or legal enforcement.
When I was a kid, I lived in a very religious farming community. The amount of bureaucracy-free cooperation was amazing. If someone got sick and couldn’t pull in their crops at harvest, we all showed up to help. If someone’s barn burned down, we built him a new one. And that farmer would join in and help others as well. This only works when you have trust. And once you get past your immediate family and friends, shared religious values are a great way to build trust. This was crop insurance and fire insurance without the need for insurance agents. We babysat each other’s kids (and you could be comfortable knowing that they weren’t being taught or shown a lifestyle you didn’t want them to learn). We shared heavy equipment like tractors and combines, comfortable in knowing that the person you loaned it to wouldn’t refuse to give it back or destroy it. No loan agreements or contracts necessary.
This type of frictionless cooperation is incredibly important in small communities, and religion helps to enable it.
It’s still all based on fictions, but for many people through history they have been very useful fictions, or they wouldn’t still be around.