In natural selection, it is genes that enable their owners to leave more surviving progeny that become more common. The idea that natural selection can favor groups, instead of acting directly on individuals, is highly controversial. Though Darwin proposed the idea, the traditional view among biologists is that selection on individuals would stamp out altruistic behavior (the altruists who spent time helping others would leave fewer children of their own) far faster than group-level selection could favor it.

But group selection has recently gained two powerful champions, the biologists David Sloan Wilson and Edward O. Wilson, who argued that two special circumstances in recent human evolution would have given group selection much more of an edge than usual. One is the highly egalitarian nature of hunter-gatherer societies, which makes everyone behave alike and gives individual altruists a better chance of passing on their genes. The other is intense warfare between groups, which enhances group-level selection in favor of community-benefiting behaviors such as altruism and religion.

A propensity to learn the religion of one’s community became so firmly implanted in the human neural circuitry, according to this new view, that religion was retained when hunter-gatherers, starting from 15,000 years ago, began to settle in fixed communities. In the larger, hierarchical societies made possible by settled living, rulers co-opted religion as their source of authority. Roman emperors made themselves chief priest or even a living god, though most had the taste to wait till after death for deification. “Drat, I think I’m becoming a god!” Vespasian joked on his deathbed.

Religion was also harnessed to vital practical tasks such as agriculture, which in the first societies to practice it required quite unaccustomed forms of labor and organization. Many religions bear traces of the spring and autumn festivals that helped get crops planted and harvested at the right time. Passover once marked the beginning of the barley festival; Easter, linked to the date of Passover, is a spring festival.

Could the evolutionary perspective on religion become the basis for some kind of detente between religion and science? Biologists and many atheists have a lot of respect for evolution and its workings, and if they regarded religious behavior as an evolved instinct they might see religion more favorably, or at least recognize its constructive roles. Religion is often blamed for its spectacular excesses, whether in promoting persecution or warfare, but gets less credit for its staple function of patching up the moral fabric of society. But perhaps it doesn’t deserve either blame or credit. If religion is seen as a means of generating social cohesion, it is a society and its leaders that put that cohesion to good or bad ends.