So the problem of a growing population is that a reason needs to be found to not kill strangers. We've happened upon a number of these over the course of our development. One example is the sanctity of blood kinship, however tenuous. The highlanders of Papua New Guinea, as described by Jared Diamond, when they encounter one another on the trails, will immediately launch into long and detailed genealogies describing the many forkings of their family trees until a connection is found and a reason not to kill one another is established. In a much more tragic fashion, African slaves did the same thing in the New World, though perhaps more to be able to maintain a sense of community and continuity as their families were repeatedly torn apart.
Another example is that of sacred hospitality. Once someone is under your roof, they are honorary members of your family and cannot be harmed. A violation of this custom and the shock it inspired was rather graphically included in George R.R. Martin's A Song of Ice and Fire series in the form of the Red Wedding, when the host slaughtered the visiting wedding party. This custom was upheld in the Biblical story of Sodom and Gomorrah when Lot offered up his daughters to the mob instead of his guests (his guests were part of his family, his daughters were just property. Valuable property, but chattel property nevertheless. Never confuse the Bible for a source of good morals.).
In both of these cases, kinship and guest rights, the third pillar of morality elucidated by Jonathan Haidt of In-Group Loyalty (also known as kin selection in evolutionary biology) is expanded to include those not of the group. These are two potential strategies for overcoming the Stranger Problem, but the first is awkward and time-consuming and the second strictly temporary. In order to overcome the Stranger Problem long term, a method needs to be found whereby the default position is "Do not kill a stranger unless he first gives you cause." rather than "Stranger! Danger! Kill! KILL!".
Once a population expands beyond the four to five hundred person limit*, a long term solution needs to be found. Initially, a monopoly on inter-personal violence can be a successful strategy. After the egalitarian band, what generally evolved was a proto-chiefdom, with a "big man" acting as a de facto authority figure by virtue of being, well, big. This co-opted the fourth pillar, Respect for Authority, and repurposed it to a long-term survival strategy for the population rather than a short term cooperative strategy. Simply put, Jim doesn't kill Dan because Big Dave will get pissed. Jim and Dan don't need to know one another for this to work, they just both have to know Big Dave. And Big Dave doesn't even have to know Jim or Dan, he just has to make sure they know him by being a visible presence.
As the population grows larger, the Big Man's presence becomes more distant; it becomes unfeasible for him to be personally known to several thousand people. The Chief/proto-king has to rely on a presence more visible from a distance. Not coincidentally, this is where conspicuous consumption became an art form; no longer a matter of biological ornamentation like our long hair or a peacock's tail, but a matter of artificial ornamentation. Hawaiian kings wore capes made from thousands of parrot feathers. Greek and Roman nobility wore clothes dyed a brilliant vermilion hue, which necessitated the gathering and careful crushing of thousands of sea snails to achieve (and which was relegated to the nobility by law on pain of death).
But this next phase didn't happen in a vacuum. Along with increased displays of wealth and power was a greater division of social hierarchy. And religion.
There are two reasons the title 'Oedipus Rex' is wrong. First, putting a Latin word in the title of a Greek play is just asinine, like eating shepherd's pie with chop sticks. More importantly, Oedipus wasn't a king (basileus), but a tyrant, one who came to power through "unofficial" channels. In ancient Greece, as in the rest of the world, the king was a sacred person/position, appointed by the gods if not semi-divine himself. Chinese dynasties were founded on the Mandate of Heaven; the Fisher King's impotence strikes the land; Herakles, Jesus, and how many others are divine sun kings, sacrificed at the end of winter to bring forth the new harvest.
In short, Respect for Authority/Elders combined with Sanctity/Purity to create religion so as to reinforce a distant hierarchy of thousands of strangers and maintain a peaceful civilization. But first, how could Sanctity/Purity play a role in this and second, what role did it play?
As I said many posts ago, Respect for Elders first comes into play as a learning tool; children are credulous to a fault and take in all they are told and store it. This expedites the learning process so that the child can learn how to survive in a hostile world in the abbreviated time his elders are available to teach him. However, as Richard Dawkins and others have noted, this comes with a price. Children absorb and take at face value nonsense just as readily as they do genuine knowledge. And then they hold fiercely to it, rejecting attempts by others to dislodge the noise. "Are you calling my father a liar?!" The Sanctity/Purity drive, which I suspect was initially simply a disgust response to keep animals from eating or drinking what was bad for them, in this model becomes a means of buttressing the Respect for Authority drive, insuring that learned information is more readily stored. The unfortunate consequence of passing on pointless superstitions about witches and blood and the full moon are a small price to pay for seeing to it that important information be passed on intact.
Further, if the information is truly valuable it will be repeatedly reinforced by contact with the real world (make a spear this way and it works, make it *this* way and you get killed by an elephant in a painful fashion, which sucks), whereas superstitions and other noise, having no real world reference, are free to mutate and change and act, in all ways, as noise. In short, valuable information stays the same, everything else is more or less harmless (unless it kills you, in which case you don't get the chance to pass it on anyway. Win-win).
I suspect that by this means, visible symbols, as tangible icons of ideas passed on from one generation to the next, became the fortunate heritors of this legacy. Sanctity/Purity attaches not just to food and water and not just to what we're taught by our elders, but also to the symbols that represent those ideas. Thus a nation's flag represents all the ideas and ideals of that nation, burning it is as much an affront as burning the nation itself. Desecrating a holy text or a holy symbol is as horrific as desecrating a loved one's corpse, not least because the ideas it represents was passed on to you by that loved one. Not everyone attaches the same importance to the sanctity of symbols, but it becomes more comprehensible in this hypothesis.
But how does it benefit a burgeoning civilization? By turning a stranger into someone who's not a stranger. It's not merely the king who benefits from the highly visible symbols of his holy office, nor just the priests in their recognizable hats. Everyone in a religion, and indeed a culture (which is often so interwoven with religion as to be inseparable), adopts certain visible signifiers. As Tevye said, "For instance, we always keep our heads covered, and always wear a little prayer shawl. This shows our constant devotion to God. You may ask, how did this tradition get started? I'll tell you. I don't know. But it's a tradition." The Jews have their yarmulkes, Muslims have their taqiyah (mostly central Asia, Eastern Europe, and Africa), Christians have crucifixes. It goes beyond that, with the hijab, the payot, and everything Amish, all cultural rather than explicitly required by the texts (maybe), but still visible identifiers for who is in and who is out.
Through the complex and involved process of looking at someone, it became possible to identify someone as being a stranger one could not kill**. And other visible identifiers said, "This person is of a higher rank than you. Go out of your way not to piss him off." or "This person is a slave, go ahead and poo on his head if you want. He'll smile and thank you for it, though his owner might not." and because all of this was wrapped up in the repurposed Respect for Elders/Sanctity/Purity drives, it was all passed along and kept intact. Unlike most superstitions, these had real-world ramifications because without them civilization would collapse.
I believe that the development of religion and civilization had to happen simultaneously. Religion can only exist in the large populations of civilization and the large populations of civilization could only exist with the support of the first. Think of religion as an epidemic of the mind; it can only sustain itself in a large population. I deliberately shifted verbs from "can" to "could", though, because I believe that we have spent the 10,000 years since the development of agriculture, civilization, and religion evolving. As with all populations, our evolution is slow and multifarious, but I suspect that one aspect is that we no longer need religion to survive. This I will discuss in Evolving Beyond Religion.
* That being the rough maximum number of people one can know, as in to put a face to a name and a name to a face. Check out a school website and match up the number of vice principals to the number of students.
** The Biblical proscription against killing should more accurately read "Thou shalt not kill thy fellow Jew". Rabbinical and Christian interpretations for thousands of years have been, "Killing a fellow Jew/Christian is murder and punishable as such. Killing a heathen? Meh. Have at it, hoss."