In his new movie Religulous, comedian Bill Maher makes wicked fun of the religiously credulous. But it turns out that the folks who believe in talking snakes and seventy-two virgins per martyr may be on to something. As whacky as some dogmas are, religions do appear to encourage generosity and honesty. At least that is the claim made in a fascinating review article, "The Origin and Evolution of Religious Prosociality" (subscription required) published in the current issue of Science.

Evolutionary biologists argue that there's nothing surprising about genetically related individuals making sacrifices for their kin: They are helping some of their own genes get passed along to the next generation. But what might cause people to make sacrifices for the good of unrelated strangers? Here, according to University of British Columbia social psychologists Ara Norenzayan and Azim F. Shariff, religion plays a key role.

The authors have winnowed three decades of empirical evidence looking for examples of religious prosociality, which they define as "the idea that religions facilitate acts that benefit others at a personal cost." Specifically, their hypothesis is that religion encourages people to sacrifice their individual fitness for the benefit of unrelated individuals or for their group. For example, young men may risk sacrificing themselves in war to protect their tribe. So how does religion encourage prosociality? The answer is that being watched by a Big-Brother-in-the-Sky tends to make believers nervous about being selfish.

This observation accords with numerous studies showing that people behave better when they think that someone may be watching them. For example, one remarkable study in 2006 found that just being under the gaze of eyes on a poster nearly tripled the contributions to an office coffee kitty. Exposing participants in a laboratory economic game to computer-generated eyespots while they played made them twice as generous as those who were not. Another study found that participants in a laboratory economic game were nearly four times stingier with other players when they thought they were anonymous than when they thought they were being observed. In other words, watched people are nicer people. Why should that be? It's because we want to have the reputation of being cooperative and prosocial so that other people, especially strangers, will want to cooperate with us.

"The cognitive awareness of gods is likely to heighten prosocial reputational concerns among believers, just as the cognitive awareness of human watchers does among believers and non-believers alike," hypothesize the authors. But supernatural oversight is even better because it "offers the powerful advantage that cooperative interactions can be observed even in the absence of social monitoring."

So does religion work, in the sense of encouraging prosocial other-regarding behavior? It depends. In one famous 1973 study, degrees of religiosity did not predict which students would stop to help someone lying on a sidewalk appearing to be sick. However, in another experiment, two players would simultaneously decide how much money to withdraw from the same envelope—if their combined withdrawals exceeded the amount in the envelope, neither would get any money. Systematically, less money was withdrawn when the game was played at religious kibbutzim than when it was played at secular kibbutzim. This finding supported the researchers' prediction that "men who participate in communal prayer most frequently will exhibit the highest levels of cooperation."

So why do religious believers tend cooperate more? In one illuminating study cited by the researchers, volunteers were given the option to raise money for a sick child's medical bills. Some would-be volunteers were told that it was very likely that they would be asked to help, while others were told that there was only a small chance that they would be called on. "In the latter condition, participants could reap the social benefits of feeling (or appearing) helpful without the cost of the actual altruistic act. Only in the latter situation was a link between religiosity and volunteering evident," claim Norenzayan and Shariff. Religion played a role when it appeared that volunteering would improve one's reputation without much personal cost.

Even more interesting are studies that find that invoking an unseen watcher enhances moral behavior. In one amazing experiment, when participants were told that the ghost of a dead student was haunting the experimental room, they cheated less on a computer test. Other researchers report that when experimental subjects were primed with religious words, they cheated significantly less on a subsequent task. Similarly, Norenzayan and Shariff found that subjects in experimental economic games were more generous when God concepts were implicitly activated before play.

The authors hypothesize that the belief in morally concerned gods who keep track of who's been naughty or nice helps create and stabilize large-scale societies. "Large groups, which until recently lacked institutionalized social-monitoring mechanisms, are vulnerable to collapse because of high rates of freeloading. If unwavering and pervasive belief in moralizing gods buffered against such freeloading, then belief in such gods should be more likely in larger human groups where the threat of freeloading is most acute," suggest the authors. In fact, a cross cultural analysis of 186 societies confirms this prediction: The larger a society, the more likely its members believe in deities that are concerned about human morality.

In small hunter-gatherer bands or subsistence farming villages, it's pretty easy to keep track of just how cooperative your neighbors are. But when groups grow to encompass thousands and eventually millions of strangers, a Big-Brother-in-the-Sky can watch how your fellow citizens behave when you can't. And even better, Sky Big Brother can punish them with eternal damnation if they swindle you. One big downside is that groups have different Sky Big Brothers, which means that "the same mechanisms involved in ingroup altruism may also facilitate outgroup antagonism." In other words, kill the infidels!

Shariff and Norenzayan note that while religion remains a powerful facilitator of prosociality in large groups, modern societies have devised secular replacements for Sky Big Brother, including courts, police, and other contract-enforcing institutions. Also, the modern world is headed toward a transparent society in which social monitoring will be nearly as omnipresent as that of a hunter-gatherer band. Increasingly sophisticated information and communication technologies will enable anyone to assess your reputation for prosociality with a few mouse clicks. Sky Big Brother is being outsourced to the Web.

Ronald Bailey is reason's science correspondent. His book Liberation Biology: The Scientific and Moral Case for the Biotech Revolution is now available from Prometheus Books.