Moths fly into the candle flame, and it doesn't look like an accident. They go out of their way to make a burnt offering of themselves. We could label it 'self-immolation behaviour' and, under that provocative name, wonder how on earth natural selection could favour it. My point is that we must rewrite the question before we can even attempt an intelligent answer. It isn't suicide. Apparent suicide emerges as an inadvertent side-effect or by-product of something else. A by-product of… what? Well, here's one possibility, which will serve to make the point.
Artificial light is a recent arrival on the night scene. Until recently, the only night lights on view were the moon and the stars. They are at optical infinity, so rays coming from them are parallel. This fits them for use as compasses. Insects are known to use celestial objects such as the sun and the moon to steer accurately in a straight line, and they can use the same compass, with reversed sign, for returning home after a foray. The insect nervous system is adept at setting up a temporary rule of thumb of this kind: 'Steer a course such that the light rays hit your eye at an angle of 30 degrees.' Since insects have compound eyes (with straight tubes or light guides radiating out from the centre of the eye like the spines of a hedgehog), this might amount in practice to something as simple as keeping the light in one particular tube or ommatidium.
But the light compass relies critically on the celestial object being at optical infinity. If it isn't, the rays are not parallel but diverge like the spokes of a wheel. A nervous system applying a 30-degree (or any acute angle) rule of thumb to a nearby candle, as though it were the moon at optical infinity, will steer the moth, via a spiral trajectory, into the flame. Draw it out for yourself, using some particular acute angle such as 30 degrees, and you'll produce an elegant logarithmic spiral into the candle.
Though fatal in this particular circumstance, the moth's rule of thumb is still, on average, a good one because, for a moth, sightings of candles are rare compared with sightings of the moon. We don't notice the hundreds of moths that are silently and effectively steering by the moon or a bright star, or even the glow from a distant city. We see only moths wheeling into our candle, and we ask the wrong question: Why are all these moths committing suicide? Instead, we should ask why they have nervous systems that steer by maintaining a fixed angle to light rays, a tactic that we notice only where it goes wrong. When the question is rephrased, the mystery evaporates. It never was right to call it suicide. It is a misfiring byproduct of a normally useful compass.
Now, apply the by-product lesson to religious behaviour in humans. We observe large numbers of people — in many areas it amounts to 100 per cent — who hold beliefs that flatly contradict demonstrable scientific facts as well as rival religions followed by others. People not only hold these beliefs with passionate certitude, but devote time and resources to costly activities that flow from holding them. They die for them, or kill for them. We marvel at this, just as we marvelled at the 'self-immolation behaviour' of the moths. Baffled, we ask why. But my point is that we may be asking the wrong question. The religious behaviour may be a misfiring, an unfortunate by-product of an underlying psychological propensity which in other circumstances is, or once was, useful. On this view, the propensity that was naturally selected in our ancestors was not religion per se; it had some other benefit, and it only incidentally manifests itself as religious behaviour. We shall understand religious behaviour only after we have renamed it.
If, then, religion is a by-product of something else, what is that something else? What is the counterpart to the moth habit of navigating by celestial light compasses? What is the primitively advantageous trait that sometimes misfires to generate religion? I shall offer one suggestion by way of illustration, but I must stress that it is only an example of the kind of thing I mean, and I shall come on to parallel suggestions made by others. I am much more wedded to the general principle that the question should be properly put, and if necessary rewritten, than I am to any particular answer.
My specific hypothesis is about children. More than any other species, we survive by the accumulated experience of previous generations, and that experience needs to be passed on to children for their protection and well-being. Theoretically, children might learn from personal experience not to go too near a cliff edge, not to eat untried red berries, not to swim in crocodile-infested waters. But, to say the least, there will be a selective advantage to child brains that possess the rule of thumb: believe, without question, whatever your grown-ups tell you. Obey your parents; obey the tribal elders, especially when they adopt a solemn, minatory tone. Trust your elders without question. This is a generally valuable rule for a child. But, as with the moths, it can go wrong.
I have never forgotten a horrifying sermon, preached in my school chapel when I was little. Horrifying in retrospect, that is: at the time, my child brain accepted it in the spirit intended by the preacher. He told us a story of a squad of soldiers, drilling beside a railway line. At a critical moment the drill sergeant's attention was distracted, and he failed to give the order to halt. The soldiers were so well schooled to obey orders without question that they carried on marching, right into the path of an oncoming train. Now, of course, I don't believe the story and I hope the preacher didn't either. But I believed it when I was nine, because I heard it from an adult in authority over me. And whether he believed it or not, the preacher wished us children to admire and model ourselves on the soldiers' slavish and unquestioning obedience to an order, however preposterous, from an authority figure. Speaking for myself, I think we did admire it. As an adult I find it almost impossible to credit that my childhood self wondered whether I would have had the courage to do my duty by marching under the train. But that, for what it is worth, is how I remember my feelings. The sermon obviously made a deep impression on me, for I have remembered it and passed it on to you.
To be fair, I don't think the preacher thought he was serving up a religious message. It was probably more military than religious, in the spirit of Tennyson's 'Charge of the Light Brigade', which he may well have quoted:
(One of the earliest and scratchiest recordings of the human voice ever made is of Lord Tennyson himself reading this poem, and the impression of hollow declaiming down a long, dark tunnel from the depths of the past seems eerily appropriate.) From the high command's point of view it would be madness to allow each individual soldier discretion over whether or not to obey orders. Nations whose infantrymen act on their own initiative rather than following orders will tend to lose wars. From the nation's point of view, this remains a good rule of thumb even if it sometimes leads to individual disasters. Soldiers are drilled to become as much like automata, or computers, as possible.
Computers do what they are told. They slavishly obey any instructions given in their own programming language. This is how they do useful things like word processing and spreadsheet calculations. But, as an inevitable by-product, they are equally robotic in obeying bad instructions. They have no way of telling whether an instruction will have a good effect or a bad. They simply obey, as soldiers are supposed to. It is their unquestioning obedience that makes computers useful, and exactly the same thing makes them inescapably vulnerable to infection by software viruses and worms. A maliciously designed program that says, 'Copy me and send me to every address that you find on this hard disk' will simply be obeyed, and then obeyed again by the other computers down the line to which it is sent, in exponential expansion. It is difficult, perhaps impossible, to design a computer which is usefully obedient and at the same time immune to infection.