Why assume that religion is a result of human evolution and not a side effect of awareness of self and mortality? Don't get me wrong, I am an immunologist and I have studied evolution for most of my life but it seems unlikely that religion would provide a survival advantage to breeding age, although maybe the foundations of religion, ritual and community would provide this advantage.
The other possibility is that because humans are aware of their individuality and their mortality, the side effect of this awareness in a tendency toward spirituality which gives rise to religion. There may be absolutely no selection involved. In evolution not every trait is there for a "reason", if a trait is not deleterious, that is it isn't selected against it often stays as long as loosing it doesn't result in the retention of energy (that is, if loosing the trait means that energy will be saved by not producing the gene product itself or the resulting activity of the gene. A good example are so called "luxury" genes that many bacteria carry which are not necessary for survival in culture but help dealing with various situations the bacterium may encounter. These luxury genes have a cost and many are energetically expensive so if in culture where these genes are not needed the bacterium often loose the genes because there is no selective pressure and there is an energetic advantage to loosing them.). All we really know is that religion does not result in a survival disadvantage up into breeding age.