Of course, it would have had to have a selective edge over non-belief in order to be part of our genes. I can think of several things; fear of danger (darkness, bad weather) could keep you safer than if you thought you could stand a chance against it, and perhaps sexual selection comes into play as well - males (or females) who conveyed a philosophy about life and how things worked may have been more in demand ("sexier") than those who simply didn't care.
Or - perhaps no selective pressure was needed. The notion that someone has to have created all this is so immediate and logical that it took several tens of thousands of years for anyone to come up with an alternative. Perhaps it was just accepted as fact from the get go. If so, genes probably aren't the answer anyway (could still be though) and we wouldn't be "hardwired" for belief. But there has been some research indicating that we are "hardwired" for it.
Agent detection evolved because assuming the presence of an agent -- which is jargon for any creature with volitional, independent behavior -- is more adaptive than assuming its absence. If you are a caveman on the savannah, you are better off presuming that the motion you detect out of the corner of your eye is an agent and something to run from, even if you are wrong. If it turns out to have been just the rustling of leaves, you are still alive; if what you took to be leaves rustling was really a hyena about to pounce, you are dead.
A classic experiment from the 1940s by the psychologists Fritz Heider and Marianne Simmel suggested that imputing agency is so automatic that people may do it even for geometric shapes. For the experiment, subjects watched a film of triangles and circles moving around. When asked what they had been watching, the subjects used words like "chase" and "capture." They did not just see the random movement of shapes on a screen; they saw pursuit, planning, escape.
So if there is motion just out of our line of sight, we presume it is caused by an agent, an animal or person with the ability to move independently. This usually operates in one direction only; lots of people mistake a rock for a bear, but almost no one mistakes a bear for a rock.
What does this mean for belief in the supernatural? It means our brains are primed for it, ready to presume the presence of agents even when such presence confounds logic. "The most central concepts in religions are related to agents," Justin Barrett, a psychologist, wrote in his 2004 summary of the byproduct theory, "Why Would Anyone Believe in God?" Religious agents are often supernatural, he wrote, "people with superpowers, statues that can answer requests or disembodied minds that can act on us and the world."
A second mental module that primes us for religion is causal reasoning. The human brain has evolved the capacity to impose a narrative, complete with chronology and cause-and-effect logic, on whatever it encounters, no matter how apparently random. "We automatically, and often unconsciously, look for an explanation of why things happen to us," Barrett wrote, "and `stuff just happens' is no explanation. Gods, by virtue of their strange physical properties and their mysterious superpowers, make fine candidates for causes of many of these unusual events." The ancient Greeks believed thunder was the sound of Zeus's thunderbolt. Similarly, a contemporary woman whose cancer treatment works despite 10-to-1 odds might look for a story to explain her survival. It fits better with her causal-reasoning tool for her recovery to be a miracle, or a reward for prayer, than for it to be just a lucky roll of the dice.
A third cognitive trick is a kind of social intuition known as theory of mind. It's an odd phrase for something so automatic, since the word "theory" suggests formality and self-consciousness. Other terms have been used for the same concept, like intentional stance and social cognition. One good alternative is the term Atran uses: folkpsychology.
Folkpsychology, as Atran and his colleagues see it, is essential to getting along in the contemporary world, just as it has been since prehistoric times. It allows us to anticipate the actions of others and to lead others to believe what we want them to believe; it is at the heart of everything from marriage to office politics to poker. People without this trait, like those with severe autism, are impaired, unable to imagine themselves in other people's heads.
The process begins with positing the existence of minds, our own and others', that we cannot see or feel. This leaves us open, almost instinctively, to belief in the separation of the body (the visible) and the mind (the invisible). If you can posit minds in other people that you cannot verify empirically, suggests Paul Bloom, a psychologist and the author of "Descartes' Baby," published in 2004, it is a short step to positing minds that do not have to be anchored to a body. And from there, he said, it is another short step to positing an immaterial soul and a transcendent God.