A result is that we have two patterns of reaction in the brain, one focusing on potential danger to us as individuals, the other, located in the prefrontal cortex, taking a more considered view of the consequences of our actions for us and others. The first is immediate, instinctive and emotive. The second is reflective and rational. We are caught, in the psychologist Daniel Kahneman’s phrase, between thinking fast and slow.

The fast track helps us survive, but it can also lead us to acts that are impulsive and destructive. The slow track leads us to more considered behavior, but it is often overridden in the heat of the moment. We are sinners and saints, egotists and altruists, exactly as the prophets and philosophers have long maintained.

If this is so, we are in a position to understand why religion helped us survive in the past — and why we will need it in the future. It strengthens and speeds up the slow track. It reconfigures our neural pathways, turning altruism into instinct, through the rituals we perform, the texts we read and the prayers we pray. It remains the most powerful community builder the world has known. Religion binds individuals into groups through habits of altruism, creating relationships of trust strong enough to defeat destructive emotions. Far from refuting religion, the Neo-Darwinists have helped us understand why it matters.

No one has shown this more elegantly than the political scientist Robert D. Putnam. In the 1990s he became famous for the phrase “bowling alone”: more people were going bowling, but fewer were joining bowling teams. Individualism was slowly destroying our capacity to form groups. A decade later, in his book “American Grace,” he showed that there was one place where social capital could still be found: religious communities.

Mr. Putnam’s research showed that frequent church- or synagogue-goers were more likely to give money to charity, do volunteer work, help the homeless, donate blood, help a neighbor with housework, spend time with someone who was feeling depressed, offer a seat to a stranger or help someone find a job. Religiosity as measured by church or synagogue attendance is, he found, a better predictor of altruism than education, age, income, gender or race.

Religion is the best antidote to the individualism of the consumer age. The idea that society can do without it flies in the face of history and, now, evolutionary biology. This may go to show that God has a sense of humor. It certainly shows that the free societies of the West must never lose their sense of God.