As stated, I don’t think that the belief in god, as such, is evolutionarily advantageous; I don’t even think it’s been around long enough to make much of an impact on our evolution as a species. However, I do think that there are several heritable traits that are both advantageous and contribute to the emergence of such a belief, most of which have already been named (by begbert2 mainly, if memory serves), but the point doesn’t seem to have caught on in the thread. Indeed, I even think that going from these traits, one would have to expect the development of religion and its interaction with society much the way we see it today, regardless of whether or not there actually are any supernatural forces to believe in.
First, we’re all superstitious. This is, I trust, rather uncontroversial – famously, even pigeons have been shown to be superstitious, which seems to point very strongly to a genetic origin of the behaviour. Mostly, this means susceptibility to a fallacious ‘post hoc, ergo propter hoc’-reasoning: we see correlations were there are none, and then, mistake those correlations for causation. In the case of the pigeons, it was easy to train them to repeat certain behaviours that led to them being fed; however, even if they were fed at completely random intervals, certain behaviours that they randomly engaged in when they were fed stabilized themselves anyway: they became simple rituals. This makes great sense – if some behaviour appears to cause a desired effect, there is at least a certain likelihood that it might again, which is the root of learning; however, the prize to pay for this is the occasional misfire, which is the source of the belief that unseen forces react to your behaviour.
Secondly, we’re pattern-recognition machines. This is just a part of how our sensory systems work: instead of laboriously building up, say, an image from visual data, by laboriously comparing each element of the image with an internal database to identify it, we go into every situation with a pre-formed expectation of what we’re likely to see; dispelling those expectations until only those over a given likelihood barrier remain is computationally far less taxing, and hence, quicker to perform. In a sense, it’s a very scientific process. The kind of expectations we have of our visual data may be shaped by many things, including experience – see, for instance, the phenomenon of ‘priming’ --, and possibly genetics (it would certainly make sense if we knew what to look for before we encounter our first tiger, and there’s at least some data that we may have an innate fear of snakes), but the mechanism at work is certainly part of our genetic blueprint. The thing is, this mechanism is subject to false positives – we see things that aren’t actually there. All that takes is a single failure to dispel one of the expectations we had going in – a single glitch. This shows itself most clearly whenever we are subject to essentially random data, and suddenly, out pops a face (something we clearly have good evolutionary reasons to look for), i.e. in the phenomenon known as pareidolia.
Thirdly, we misattribute intention. This is similar to the previous section, only acting not on a sensory, but rather a cognitive level. I don’t really wish to come up with the EP mainstay of the hunter-gatherer in the jungle running away from a tiger that’s not actually there and surviving vs. the hunter-gather that missed the tiger that was there, and thus, also missed the chance of passing on his genes, since it would rub some posters the wrong way, but in a way, it’s pretty much that – it’s less dangerous to believe something that doesn’t actually want to eat you does, than it is the other way around. In the absence of rational explanations for the forces at work in nature, an animistic misattribution of intention is the most successful heuristic.
With these three points, we have essentially all we need for most religions – unseen, intentional forces populating the world around us which we can influence through our behaviour. Knowing about these three human traits, one would have to predict belief in the existence of supernatural entities, and ritualistic behaviour surrounding this belief, whether or not such entities actually exist.
So, it’s not the case that believing in god, as such, is evolutionarily advantageous; however, there are evolutionarily advantageous traits that may well – and, I believe, should be expected to – lead to such a belief.