The BBC published its second of two posts on the origin of religion, and it’s a doozy. The first article explored the deep roots of religion in the behavior of various non-human species: How and why did religion evolve? (BBC)
This second part takes on why religious thought exists in humans specifically, drawing on a variety of theories and disciplines, from evolutionary psychology, to anthropology, to sociology, to neuroscience. The thinkers the author reference in the article include Pascal Boyer, Daniel Dennett, Andrew Newberg, Justin Barrett, Robin Dunbar, and Robert Bellah.
I’m going to pair this with an older article from The Atlantic, Is God and Accident?, which posits that religion was, in essence, an “accident” due to the unique way our brains have evolved to process information, and covers some of the same ground. I’ll supplement these with other sources.
Two common theories of why religion developed are: 1.) religion evolved to calm our existential fear of death, and 2.) religion evolved to create intragroup cohesion via shared concepts and rituals (i.e. to bind people together). Or, religious beliefs are shibboleths: they evolved to divide the social world into “us” and “them.”
But there are a few problems with these narratives. When you take a look at most primitive religions, there is no “big picture” philosophical explanation for the mystery of human existence. There is no “country club” afterlife that people are looking forward to as in Western (particularly American Protestant) Christianity. There is no “better place” after death—just a different one. In many ancestor-veneration cultures (which I have proposed as the original form of religion), the ancestors simply dwell “under the earth”. It’s hardly a pleasant afterlife.
This chthonic idea—that spirits dwell somewhere below the earth—is so universal that I think there must be something fundamental to it. It was present in all the Near Eastern religions, and is implicit in the Hebrew term for the grave, sheol (Heaven and Hell are conspicuously absent from the Old Testament). It was present in Greek culture too. Even the remote Pirahã of the Amazon believe the spirits of their departed ancestors dwell somewhere beneath the earth.
My guess is that this comes from our tradition of disposing with dead bodies by ritually burying them, which goes all the way back to the dawn of cognitively modern humans. Burials—especially with grave goods—are used by archaeologists as a proxy for when something like religion first emerged.
Here’s a good description of death rituals and beliefs in the Ancient Near East (ANE):
In death a person gave up his or her breath and became a ghost (etemmu). The bodies of the deceased were sometimes buried under a special section of their own house rather than in a separate tomb. As in other ANE cultures, the oldest son was responsible for maintaining such duties as providing the dead with food and drink and other supplies; he was also expected to regularly pronounce their names to ensure that the dead were not forgotten by the living.
Particularly important in this regard was the kipsu banquet, to which dead ancestors would be invited and from whom blessing on the living would be sought. As in other ANE thought, the living could contact the dead (through a medium or necromancer) and the ghosts of the dead could affect the circumstances of the living. Restless ghosts were considered particularly malevolent and were thus especially feared. Accordingly, imitative magic and numerous spells were designed to ward off such malevolent ghosts or demons, such as those thought to attack people sexually at night, or those who were considered responsible for what we refer to as cot death or sudden infant death syndrome. p. 12
The underworld itself was commonly referred to as ‘the Great City’, ‘the Great Below’, or ‘the Land of No Return.’ It was believed to have three tiers: the lowest level was the court of the gods of the underworld; the middle level was the watery realm of the deity Apsu; and the upper level immediately under the earth’s surface was the ‘residence of the spirits of men’. The entrance was supposedly in the west, where Shamash (the sun god) was believed to go down at night and travel under the earth before resurfacing in the east the following morning. To access the underworld, the dead had to cross a river with the aid of a boatman called Remove-hastily. Presumably the sooner he carried out his task the better! 
Meanwhile, in ancient Greek tribal culture:
At death the psyche or soul, which entered the body at birth, leaves again like a puff of wind and – so long as the deceased has been properly buried – goes to the underworld. Here the dead exist as insubstantial ‘shades’ or ‘shadows’ of their former selves, without strength or pleasure. While normally confined to the realm of the dead, the deceased may occasionally reappear as ghosts who can haunt or communicate with the living. As in the ANE, proper care of the dead was therefore paramount; indeed, improper care could bring their ghosts back to haunt the negligent, because in Greek mythology the unburied dead were not allowed to enter Hades.
[Hades] is portrayed as a remote place, far below the earth, dark and dismal, and utterly devoid of hope. For the most part, all the dead, regardless of social rank or status, share the same experience; this was clearly not a happy one – even for the heroic dead. Achilles, for example, famously remarks that he would rather be the hired servant of a poor farmer on earth than lord of all the withered dead in the underworld’ (Od. 11.489-491). Yet this was not perceived as a place of punishment or retributive justice; rather, it was simply the grim and gloomy destiny that all men would inevitably share. There was no hope of any physical return from death; the only hope of immortality lay in making a name for oneself, one that would be perpetually remembered by those on earth. So all in all, Homer’s view of death and the afterlife is almost entirely negative. ibid.
And China, with its long (and enduring) tradition of ancestor worship, was quite similar:
According to ancient beliefs, each person had a spirit which required the offering of sacrifices, not just royal figures. It was thought that an individual had two souls. After death, one of these souls, the po, rose to heaven while the other one, the hun, remained in the body of the deceased. It was this second soul that required regular offerings of nourishment. Eventually, the hun soul would migrate to the fabled Yellow Springs of the afterlife, but until that time, if the family did not want the spirit of their dead relation to trouble them as a wandering hungry ghost, they had to take certain precautions. The first was to bury the dead with all the essential daily objects (or models of them) they would need in the next life from food to tools. Next, to ensure the corpse remained at peace, it was necessary to offer appropriate and regular offerings.
Ancestor Worship in Ancient China (Ancient History Encyclopedia)
In The Ancient City, Fustel de Coulanges, who also argued for ancestor worship as primordial form of religion and the key to understanding ancient cultural institutions, notes the similarities between Greek, Roman and Hindu ancestor worship:
The Hindu, like the Greek, regarded the dead as divine beings, who enjoyed a happy existence; but their happiness depended on the condition that the offerings made by the living should be carried to them regularly. If the Śrāddha for a dead person was not offered regularly, his soul left its peaceful dwelling, and became a wandering spirit, who tormented the living; so that, if the dead were really gods, this was only whilst the living honored them with their worship.
The Greeks and Romans had exactly the same belief. If the funeral repast ceased to be offered to the dead, they immediately left their tombs, and became wandering shades, that were heard in the silence of the night. They reproached the living with their negligence; or they sought to punish them by afflicting them with diseases, or cursing their soil with sterility. In a word, they left the living no rest till the funeral feasts were re-established. The sacrifice, the offering of nourishment, and the libation restored them to the tomb, and gave them back their rest and their divine attributes. Man was then at peace with them…
These human souls deified by death were what the Greeks called demons, or heroes. The Latins gave them the name of Lares, Manes, Genii. “Our ancestors believed,” says Apuleius “that the Manes, when they were malignant, were to be called larvae; they called them Lares when they were benevolent and propitious.” Elsewhere we read, “Genius and Lar is the same being; so our ancestors believed.” And in Cicero, “Those that the Greeks called demons we call Lares.” The Ancient City, p. 17
So, it turns out that most ancient religions weren’t all that reassuring when it came to life after death after all! Nor was any kind of supernatural reward or punishment involved. Mostly, it seems, the dead were just ephemeral ghosts who had to be buried with the proper rituals and appeased through regular feasts and commemorations so that they wouldn’t come back to haunt the living. As Bruce Carpenter remarked of Balinese ancestor worship, “It’s like having a representative in Congress,” describing the ongoing reciprocal relationship between families and their departed ancestors.
This seems to be almost universal in the large cultures we are familiar with. We see it all over the world. The concepts of Heaven or Paradise (along with Hell) came much, much later in history, and mostly in Western monotheistic cultures (the word Paradise comes from Persia and signifies a walled garden). You will find little of this cushy afterlife in say, for example, traditional Chinese or Japanese religions, much less in other more remote cultures.
[As an aside, I had this thought: Is it possible that cultures that buried their dead saw them as dwelling underneath the earth, whereas cultures who cremated their dead saw them as ascending up to heaven, which is what smoke does when bodies are cremated in the open air? The symbolism of smoke representing a release of the soul floating upwards has been used in some belief systems. This is worthy of exploration.]
Similarly, while it’s true that religious beliefs do often serve as a kind of cultural glue which binds societies together, it does not explain the proliferation of supernatural entities, from ancestral spirits to hungry ghosts to malevolent demons to guardian angels to tutelary deities, to capricious gods. Nor does it explain these diverse approaches to the afterlife, or why there should even be an afterlife at all! In fact, many religious beliefs and practices actually seem counterproductive. Often relatives go deeply into debt to perform funeral rites that look silly to outsiders, just so their dead relatives are sated and don’t curse them with bad luck. As the anthropologist Lionel Tiger remarked, “As a social scientist I wanted a deeper explanation for this otherwise remarkable activity. When you think of the cost of religion—the buildings, the tax exemptions, the weekly offering—it’s not trivial, it’s simply not trivial. If only out of respect, one has to pay attention to this.”
Also recall that primitive religions pretty much never feature either Moralizing High Gods (MHG), not Broad Supernatural Punishment (BSP); two key features of doctrinal monotheistic religions. As we saw above, most invisible entities are potentially mischievous, petty, and cruel, and require constant appeasement. There is no greater existential “reason for existence” articulated by any of these religions. You live, and then you die, and that’s pretty much it; and the afterlife isn’t much better than this one—maybe even worse!
(Of course, some have proposed that the very wastefulness of religion is a form of honest signaling—”skin in the game,” as it were. If we have to contribute something costly to participate, and have something significant to lose, the thinking goes, we are less like to be a cheater or a free rider. Of course, this doesn’t explain the reasons for supernatural entities or an afterlife.)
Thus, neither the “religion as anodyne/opiate” nor the “religion as social glue/fraternity/shibboleth” ideas satisfy all the questions surrounding the origin of religious belief, especially the ones we are most interested in. Something else must be at work. But what?
[T]he religion-as-opiate theory fits best with the monotheistic religions most familiar to us. But what about those people (many of the religious people in the world) who do not believe in an all-wise and just God? Every society believes in spiritual beings, but they are often stupid or malevolent.
Many religions simply don’t deal with metaphysical or teleological questions; gods and ancestor spirits are called upon only to help cope with such mundane problems as how to prepare food and what to do with a corpse—not to elucidate the Meaning of It All.
As for the reassurance of heaven, justice, or salvation, again, it exists in some religions but by no means all. (In fact, even those religions we are most familiar with are not always reassuring. I know some older Christians who were made miserable as children by worries about eternal damnation; the prospect of oblivion would have been far preferable.)
So the opiate theory is ultimately an unsatisfying explanation for the existence of religion.
The major alternative theory is social: religion brings people together, giving them an edge over those who lack this social glue. Sometimes this argument is presented in cultural terms, and sometimes it is seen from an evolutionary perspective: survival of the fittest working at the level not of the gene or the individual but of the social group. In either case the claim is that religion thrives because groups that have it outgrow and outlast those that do not.
In this conception religion is a fraternity, and the analogy runs deep. Just as fraternities used to paddle freshmen on the rear end to instill loyalty and commitment, religions have painful initiation rites—for example, snipping off part of the penis.
Also, certain puzzling features of many religions, such as dietary restrictions and distinctive dress, make perfect sense once they are viewed as tools to ensure group solidarity. The fraternity theory also explains why religions are so harsh toward those who do not share the faith, reserving particular ire for apostates…
This theory explains almost everything about religion—except the religious part. It is clear that rituals and sacrifices can bring people together, and it may well be that a group that does such things has an advantage over one that does not. But it is not clear why a religion has to be involved. Why are gods, souls, an afterlife, miracles, divine creation of the universe, and so on brought in? The theory doesn’t explain what we are most interested in, which is belief in the supernatural.
Is God an Accident? (The Atlantic)
Hence the “accidental” (or side effect) theory of religion. As the Atlantic article states, “Enthusiasm is building among scientists for a quite different view—that religion emerged not to serve a purpose but by accident…” : In the terminology of evolutionary biology, “religion is either a spandrel or an exaption.”
.. the term “spandrels” [is] a structure that merely follows from the existence of some other (evolved) structures, without itself being an adaptation. “Exaptation” refers to new roles played by evolutionarily old features that are adaptations in the strict sense of the term. Adaptations in this sense are features that are selected to perform their current function. …Standard examples are the reptilian bones of the jaw that get adopted for the middle ear by mammals. Our ability to do mathematics is an exaption of various syntax-modules and modules that do trivial combinatories (“Are any of my babies missing?”). The ability to get embroiled in fictional worlds is an exaption of our ability to conduct thought-experiments as a part of forward planning. 
These “spandrels” and “exaptions” became co-opted by our brains to create religion. And, once that happened, religion, in turn, encouraged reciprocal altruism to evolve. In other words, we used religion—a by-product of our own cognitive evolutionary legacy—to bootstrap our way into becoming the unusually cooperative species we are today.
When one thinks of the many pages that have been written about religion uniting people into a moral community, it is not particularly surprising to learn that some anthropologists, biologists, and philosophers now claim that it is precisely religion that has helped reciprocal altruism to evolve. Ferren MacIntyre, for example, argues that religious affiliations have acted as a kind of “kinship surrogate” that helped our ancestors to develop cooperation among large groups of nonkin.
In the “standard model” of the cognitive science of religion, however, religion is instead a by-product based on “runaway” evolutionary processes extended beyond their initial domain. Evolution has built certain structures and mechanisms of mind that are adaptations to certain Pleistocene conditions; religion is made possible by these structures and mechanisms, although they did not originally develop for this purpose. 
Basically, according to this theory, the core characteristics of all religions boil down to two primary things:
First, we perceive the world of objects as essentially separate from the world of minds, making it possible for us to envision soulless bodies and bodiless souls. This helps explain the ubiquitousness of belief in disembodied souls, or “spirits”, in whatever cultural form they happen to take. Even nineteenth-century rationalists made serious attempts to contact the dead (e.g. William James and Arthur Conan Doyle)
Purely physical things, such as rocks and trees, are subject to the pitiless laws of Newton. Throw a rock, and it will fly through space on a certain path; if you put a branch on the ground, it will not disappear, scamper away, or fly into space. Psychological things, such as people, possess minds, intentions, beliefs, goals, and desires. They move unexpectedly, according to volition and whim; they can chase or run away. There is a moral difference as well: a rock cannot be evil or kind; a person can…
Understanding of the physical world and understanding of the social world can be seen as akin to two distinct computers in [the] brain, running separate programs and performing separate tasks. The understandings develop at different rates: the social one emerges somewhat later than the physical one. They evolved at different points in our prehistory; our physical understanding is shared by many species, whereas our social understanding is a relatively recent adaptation, and in some regards might be uniquely human…
For those of us who are not autistic, the separateness of these two mechanisms, one for understanding the physical world and one for understanding the social world, gives rise to a duality of experience. We experience the world of material things as separate from the world of goals and desires. The biggest consequence has to do with the way we think of ourselves and others. We are dualists; it seems intuitively obvious that a physical body and a conscious entity—a mind or soul—are genuinely distinct. We don’t feel that we are our bodies. Rather, we feel that we occupy them, we possess them, we own them.
This duality is immediately apparent in our imaginative life. Because we see people as separate from their bodies, we easily understand situations in which people’s bodies are radically changed while their personhood stays intact. Kafka envisioned a man transformed into a gigantic insect; Homer described the plight of men transformed into pigs; in Shrek 2 an ogre is transformed into a human being, and a donkey into a steed; in Star Trek a scheming villain forcibly occupies Captain Kirk’s body so as to take command of the Enterprise; in The Tale of the Body Thief, Anne Rice tells of a vampire and a human being who agree to trade bodies for a day; and in 13 Going on 30 a teenager wakes up as thirty-year-old Jennifer Garner. We don’t think of these events as real, of course, but they are fully understandable; it makes intuitive sense to us that people can be separated from their bodies, and similar transformations show up in religions around the world. 
Second, our system of social understanding overshoots, inferring goals and desires where none exist. This makes us intuitive animists and creationists.
In 1944 the social psychologists Fritz Heider and Mary-Ann Simmel made a simple movie in which geometric figures—circles, squares, triangles—moved in certain systematic ways, designed to tell a tale. When shown this movie, people instinctively describe the figures as if they were specific types of people (bullies, victims, heroes) with goals and desires, and repeat pretty much the same story that the psychologists intended to tell. Further research has found that bounded figures aren’t even necessary—one can get much the same effect in movies where the “characters” are not single objects but moving groups, such as swarms of tiny squares.
Stewart Guthrie, an anthropologist at Fordham University, was the first modern scholar to notice the importance of this tendency as an explanation for religious thought. In his book Faces in the Clouds, Guthrie presents anecdotes and experiments showing that people attribute human characteristics to a striking range of real-world entities, including bicycles, bottles, clouds, fire, leaves, rain, volcanoes, and wind. We are hypersensitive to signs of agency—so much so that we see intention where only artifice or accident exists. As Guthrie puts it, the clothes have no emperor. 
As a direct consequence of the evolution of the human social brain, and owing to the importance of our theory-of-mind skills in that process, we sometimes can’t help but see intentions, desires, and beliefs in things that haven’t even a smidgeon of a neural system. In particular, when inanimate objects do unexpected things, we sometimes reason about them just as we do for oddly behaving—or misbehaving—people. More than a few of us have kicked our broken-down vehicles in the sides and verbally abused our incompetent computers. Most of us stop short of actually believing these objects possess mental states—indeed, we would likely be hauled away to an asylum if we genuinely believed that they held malicious intent—but our emotions and behaviors toward such objects seem to betray our primitive, unconscious thinking: we act as though they’re morally culpable for their actions.
So it would appear that having a theory of mind was so useful for our ancestors in explaining and predicting other people’s behaviors that it has completely flooded our evolved social brains. As a result, today we overshoot our mental-state attributions to things that are, in reality, completely mindless. And all of this leads us, rather inevitably, to a very important question: What if I were to tell you that God’s mental states, too, were all in your mind?…
As we became smarter and our brains larger, we dragged along this “cognitive baggage” of our evolutionary past. It remains with us to this day, and forms the basis of many of the idiosyncratic beliefs we associate with religious belief, and superstition more broadly.
But there’s still a bit more to it than that. With the help of that BBC article, we’ll take a closer look at some of the “cognitive modules” that helped religious belief evolve. My understanding is that while each of these modules is important in the construction of religious thought, none of them by themselves is sufficient to account for religion. Rather, it is the intersection of all of them that gives rise to the uniquely human phenomenon we call “religion” (although ancient societies would have not made any such distinction between religion and other aspects of their social and cultural lives).
 “Death and the Afterlife – Biblical perspectives on ultimate questions,” by Paul R Williamson, p. 13
 Supernatural Agents: Why We Believe in Souls, Gods, and Buddhas, by Iikka Pyysiainen, p. 31
 Thomas Forster Tries to Understand Julian Jaynes, p. 5 (PDF)
 Is God an Accident? The Atlantic, December 2005
 Are You There God? It’s Me, Brain. Slate Magazine, February 2011