Why Did Religion Evolve? by Nigel Barber, Psychology Today, June 13, 2012
The origins of religion are to be found neither in its boost to reproductive fitness and fecundity, as the article above alleges, nor in religion's explanatory power and comfort.
Religion evolved along with other social structures and functions such as leadership (politics) and the distribution of wealth (economics). Primarily it emerged in the earliest stages of Homo's cultural evolution as a means of exerting social influence and control. It agents for establishing such control were its practitioner's who proclaimed their possession of superhuman abilities to understand and control superhuman beings and supernatural processes they alleged existed. They called these supernatural beings gods and their activities the various workings of Nature and the cosmos.
Ancient leadership, from early Homo into the earliest agrarian and urban civilizations, wasted no time in bringing religious cosmology under its firm control as an adjunct to brute force for maintaining control of the group (band, tribe, city, empire, civilization). Since those distant times, for the most part, human leadership has succeeded in maintaining its control over religion. However, today one finds leadership sometimes subordinating itself to religion when it is expedient or otherwise useful for leadership to do so, and one sometimes finds religion touting itself as liberated from leadership and as an empowering worldview of the individual.
Regardless, politics and religion have always been and will remain comfortable bedfellows.
Look for the origins of religion in our early cultural evolution as a form of social control, not in it's Darwinian fitness, solace, or explanatory power. The latter approach, as the above article exemplifies, is a biased speculative glance into our imagined ancient past using the worldview of the present.
As for species' future, the key for human progress, and very likely our and the Earth's survival, is to transform religion away from a focus on the supernatural to a reverence for a secular-scientific, factual understanding of Humankind, Nature, and the cosmos.