'Religion is a cultural universal, and its practice is observed in every known human society. However ... recent evolutionary psychological theories suggest that religiosity may not be an adaptation in itself but may be a byproduct of other evolved psychological mechanisms variously called the "animistic bias" or the "agency-detector mechanisms."
These theories contend that the human brain has been selected to overinfer agency - personal, animate, and intentional forces - behind otherwise natural phenomena whose exact causes cannot be known. This is because overinferring agency - and making a Type I error of false positive - makes you a bit paranoid, but being paranoid is often conducive to survival. In contrast, underinferring agency - and making a Type II error of false negative - can result in being killed and maimed by predators and enemies that were incorrectly assumed not to exist. So, evolutionarily speaking, it's good to be a bit paranoid, because being paranoid can often save your life. Religiosity - belief in higher powers - may be a byproduct of such overinference of agency and intentional forces behind natural phenomena.'
More information on overinference, Error Management Theory, Type I and II errors and the benefits of paranoia from an evolutionary point of view can be found in the linked articles 'Why Do We Believe in God?' Part I and Part II.
* * *
It is advantageous for survival for groups of humans to cohere, which includes believing the same things (not only from a religious point of view – the survival-orientated paranoia described above should work best when it leads to a generally integrated set of beliefs and behaviour in a group of humans). Resistance to group behaviour and beliefs and the resulting unrest would thus be met with sanctions, as it is felt to be potentially harmful.
A lengthier discussion can be found at: RichardDawkins.net
There is also a somewhat sinister implication here: if group cohesion is best ensured by the establishment of a hierarchical social/power structure, then such power structures themselves (of which religion is one) become effective tools in ensuring group cohesion. Thus we encounter a worrying form of error management theory at a deeper social level – even though ceding power to a ruling elite (political, religious, social, etc.) may be detrimental to the wellbeing of an individual (perhaps acutely so), it is nevertheless felt to be advantageous to the survival of a society (or humanity more generally).
The last distinction is itself alarming, as such patterns often lead to political or religious conflict (most obviously exemplified by wars and oppressive regimes) which, although they cost the lives of many people, apply the ‘survival of the fittest’ dictum to groups rather than individuals, the most ‘forcefully resilient’ group having the best chance of survival, again assuming a high degree of social cohesion.