I would imagine the answer to this question would be that religion tends to cause greater compliance of individuals within society, so it is pro-society. Plus these religions tend to incorporate some knowledge obtained by trial and error, an example of this is the fact that in Judaism the consumption of swine is forbidden which would be an evolutionary advantage seeing how swine is notorious for its parasitic constituents. Additionally religion offers an explanation for some of the phenomena that were once and still are poorly understood. Such things include near-death experiences. It also adds to motivation and tends to confer some other advantages such as a decreased rate of suicide due to the condemnation of suicide by the majority of religions.
In terms of genetic evolution, religion itself cannot really be considered to have an evolutionary advantage or disadvantage, as it is not anchored in any genes. This means that it is not an evolutionary trait and hence the principles of evolution do not apply to it. However, religion is a product of underlying capabilities of the brain (for example imaginative capacity?), and these are genetic and evolutionarily advantageous. Aside from this, asking for the 'evolutionary purpose' of anything is the wrong way to approach the topic, as things do not evolve to have a purpose but they simply evolve and stick around unless they produce a net disadvantage compared to a competing version of the same trait.
You could look at religion from a memetic point of view however, i.e. as an idea which competes with other ideas. The idea of religion has many aspects to it that would help it to 'survive', i.e. not be forgotten. These include the drive to tell other people about it, ease of understanding, the claim of exclusivity, addressing many social cravings, and filling in gaps of knowledge for which explanations are desired.