When I think about the role of religion in our lives I think about three things. Our evolved cognitive abilities that are effectively static; what I will call our "intuition". Our cognitive abilities that are malleable, upgradeable and learned; or our "rationality". And lastly our environment, past and present.
When belief, argument, logic and storytelling were invented by nature they were there to support and augment instinct, emotion, and reflex. Lets call these two categories of mental tools I just mentioned "rationality" and "intuition". Our intuition was built to guide us in our original environment, not the one we has since created.
When we started to alter our environment radically, as we did with agriculture, our environment and our intuition started to fall out of synch. What we want to do at our basest level, is what would be good for us in the environment that evolved in(1). But as we got further and further away from the stimuli and behavioral choices and outcomes that we grew up with, we needed more and more cultural support to keep our behavior in line with our environment.
Eventually some of our base instincts came to be seen as evil impulses that needed to be controlled. But these instincts were just the instincts that no longer had good outcomes. Our inborn attitudes toward the four F's (food, fighting, fleeing and mating) are the most critical, the most resistant to change. But because we moved into villages, towns and finally cities, our base instincts became increasingly problematic as our environment was increasingly altered.
I don't know what exactly our unalterable instincts are, what our original evolutionary context was, but all I need to point out here is that our intuition (our original guide to successful behavior) is too slow to alter and couldn't keep up with the changes that we made to our surroundings. And so we put to use our rational capacities to figure out how to make sense of a world in which what we wanted led to disaster and what we loathed lead to success.
What we needed then was a set of cultural technologies (2) that would get us to behave in successful ways for the situation we were in. But in the same way that brains aren't truth machines, religions are not cosmology describers. Religions were a sort of instinct prosthesis, a guide to behavior that could be altered faster than the speed of evolution.
And it was the best technological solution to the problem that we had that was available. It kept our behavior adaptive in a world that had changed radically. But in this role religion must remain somehow empirical to stay useful. And for a long time what kept this more or less true was multidimensional. 1) the culture and technological innovation wasn't all that fast 2) the church used its power to actively dissuade change 3) the church used changes in interpretation to change what the religion meant to keep up with what changes did happen.
What has really damaged religion in the last ~200 years is that it wasn't agile enough to cope with the explosion of technological and cultural changes that have happened in that time. Religion really has failed us in the last couple of hundred years, but one of the roles that it was supposed to serve, that of instinctual prosthesis is still necessary. We are still apes with shoes, assault rifles and the instincts that nature imbued us with before we invented the ax.
Since religion has lost its adaptive edge (either the enlightenment or the modernist period, I'm honesty not sure which) the fight has been against the institution of religion. And not for no reason, the church has many problems and a lot of cultural power to cause those problems. But what that fight has ignored more often than not is that there is both baby and bathwater.
But the question is now posed, what can we use to help ourselves out? We are out of our element from and evopsych perspective and the tool that we built (religion) isn't up to the task anymore. God is dead, now what?
Basically what I am saying is that we needed religion to survive the agricultural revolution and we need something better to survive the industrial.
(1) I am being deliberately nondeterministic here, I don't feel like we know for sure what that environment was.
(2) technology includes techniques as well as objects