Over-active Pattern Matching
One key element is our phenomenal ability to find patterns. Scientists have recently started to capitalize on this.
The “Rosetta” project followed the same pattern as many other distributed computing projects, at least at the start. David Baker and his colleagues were dealing with the difficult problem of protein folding. These little molecules are the workhorses of all living things, and do everything from speed up chemical reactions to transmit signals in your brain… yet they’ve been remarkably difficult to study. The problem is not with our understanding of molecular forces, or the blueprints to make any protein, but the sheer number of computations required to combine both into a folded protein. On a single computer, crunching through the numbers can take years. 
Baker decided to solve that problem by distributing the work; his group created a software program that could do protein folding, then gave it away to anyone interested. As of this writing, about 30,000 people are running Rosetta on at least one computer,  and speeding up the process by at least that many times. Every single one of them is doing this voluntarily, with their only compensation being a pretty picture of the folding process in action.
Soon, however, Baker’s group was fielding emails about those pretty pictures. The people running Rosetta noticed the software would get “stuck” in places, or waste time on solutions that even a non-expert could tell would go nowhere. They wondered if there was any way to “nudge” the software with hints.
Baker decided to take the hint himself, and hired Zoran Popović and David Salesin to turn his science program into a game called “foldit.” Users could now do much more than help their computer along; they could team up with others to solve “puzzles,” compete with others to earn a high score, or even write their own scripts to help remove some of the grunt work.
Adding humans into the mix paid off. One user named “Vertex” came up with the “Blue Fuse” helper script, and with refinements developed by others it rapidly became the most popular such helper on “foldit.”  When Baker had a look at the code, however, he was astonished to find it was a near-duplicate of an algorithm his lab was privately testing. Some comparisons between the two revealed that in seven months, a community of novices had managed to best years of research by experts in protein folding.  Other citizen science projects have found the same pattern; pooling together the opinions of non-experts gives results equal to what an expert could churn out, in a fraction of the time.
This ability to suss out patterns comes at a cost, however. As mentioned in the Witness proof, we’re also prone to finding patterns that don’t exist. It takes a minor stretch of someone else’s imagination to start assigning a language to random sounds, or guess there’s a mind behind mindless processes. From that, gods can be formed.
Back in the Morality proof, I used a little game theory to describe how morality could be evolved as an instinct. In the process, I also showed how classism could also be bred into our bones.
Henri Tajfel made a career out of studying this, in fact. One fascinating study asked people to judge the length of lines. The participants were split into two groups, one of which was given the lines without any labels. The other group had their lines labelled by length, either “A” if the line was shorter than average or “B” if the line was longer. The second group automatically lumped lines by label, consistently guessing longer lengths for short lines and shorter lengths for longer ones to match up with their expectations for the two categories. The first group didn’t show any bias. 
What applies to lines also applies to people. Here’s an example from Tajfel himself:
The boys, who knew each other well, were divided into groups defined by flimsy and unimportant criteria [in this case, they were told it was how well they could count groups of dots; in reality, the researchers randomly assigned groups]. Their own individual interests were not affected by their choices, since they always assigned points to two other people and no one could know what any other boy’s choices were. The amount of money were not trivial for them: each boy left the experiment with the equivalent of about a dollar. Inasmuch as they could not know who was in their group and who was in the other group, they could have adopted either of two reasonable strategies. They could have chosen the maximum-joint-profit point of the matrices, which would mean that the boys as a total group would get the most money out of the experimenters, or they could choose the point of maximum fairness. Indeed, they did tend to choose the second alternative when their choices did not involve a distinction between ingroup and outgroup. As soon as this differentiation was involved, however, they discriminated in favour of the ingroup. The only thing we needed to do to achieve this result was to associate their judgements of numbers of dots with the use of the terms “your group,” and “the other group” in the instructions […]
Tajfel, Henri. “Experiments in intergroup discrimination.” Scientific American 223.5 (1970): 96-102.
It’s a sobering thought. If we can start favouring an ingroup and punishing an outgroup, along lines as arbitrary as how good we are at counting dots, what are the odds of us carving lines in the sand over skin colour, or genitalia?
Or for that matter, beliefs and rituals?
There’s two key differences, however. You can’t change genitalia or skin colour, and gradations and variety are guaranteed.  Behaviour, however, is easily changed, allowing anyone to hop from outgroup to ingroup. It’s quite possible then for a behaviour-based ingroup to grow in size and dominate over all their outgroups. At a magical tipping point, the special treatment enjoyed within the ingroup outweighs any harm that could be inflicted by an outgroup, and the reverse is true from any outgroup’s point of view. There’s a strong incentive to switch, which only grows as more people give in. The eventual result is the disappearance of all outgroups, and the people that remain are nicer and more trusting to one another than they would have been in a non-classist situation.
In theory, of course. There are a number of practical barriers to this utopia.
For one, the ease that we divide ourselves means that in-groups are prone to splintering along the most trivial lines. This becomes a problem when the in-group cannot provide the benefits it once used to, or there is no real out-group, as there’s very little enforcing group cohesion. If only there were some way to invent an out-group, either by spreading tales of extreme debauchery and mayhem about a group that doesn’t live nearby, or simply making up an all-powerful one out of, say, folklore or leftover gods. If only.
I alluded to another in the Morality proof. Classism is easy prey for cheaters, who will happily wave around the in-group symbols but refuse to act as nice; the obvious counter is to add costly symbols and rituals, such as piercings and other body modifications. A less obvious one is to invoke an always-present, always watching police-thing to ensure everyone toes the line.
While the above two components are enough to get a religion off the ground, they don’t explain why religions have such staying power. For that, you need one more ingredient: evolution.
As I discussed in my chapter on the Design/Teleological proof, evolution applies to far more than biology. It’s a general-purpose feedback loop that works equally well with culture and ideas. Religions are no exception, as they have all the basic requirements.
Traditions and rituals are easily passed from person to person, forming new copies of themselves. African-Americans brought over to the United States for the slave trade readily absorbed the religion of their captors, to the point that they are more likely to be Christian than those of European descent. 
The Christianity they adopted differs in important ways, however. African-Americans placed far more emphasis on music; while their European counterparts specialized in boring chants of ancient lyrics, they formed lively quoirs of freshly-minted words and created an entire musical genre known as “gospel.”  While their fellow European citizens became useed to dealing with a distant, aloof church system, African-Americans made theirs keenly interested in social justice and humanitarian causes.  By changing Christianity to suit them, they made it more suitable and thus tougher to walk away from.
This hasn’t escaped the notice of non-Africans. Faced with emptying pews, church leaders elsewhere have started adopting the innovations of African-Americans to woo churchgoers back. The use of popular music is on the uptick,  as well as an emphasis on charity and improving the lot of your fellow human. 
Self-replication, variation, limited environment, and feedback. Every aspect is there, creating a feedback loop of self-preservation replication.
While evolution is the key ingredient, that doesn’t rule out some spices to help seal the deal.
We are social creatures, at heart. Like dogs, bats, prairie dogs, and our fellow apes, we rely on teamwork to survive. Not surprisingly, the process of evolution has strengthened that by planting various rewards within us.
[TODO: friendship bonus]
[TODO: parent bonus]
These same rewards could be redirected to other ends, however. Making friends with an imaginary being would convey some of the same rewards granted by hanging around with a real-life friend, only this imaginary being will never talk back to you. Having an imaginary being as a parent would provide a sense of security that a real-life parent could never provide.
Fear of Death
[TODO. But see “Terror Management Theory“]
How Religion Started
All merged to form religion. Hunter-gatherer society had good punishment for misbehavior, in the form of ostracism, but as population grew it became less useful. No police around to enforce rules, so who could? Religion evolved a solution with divine punishment via afterlife and a central authority, which made social organization of large groups much easier. Can see this in tribal spirituality vs. Early religions.
Thus: religion is social structure that benefits members by policing group behavior via a supernatural justice system. Evidence:
- As countries get wealthier and more secure, religosity drops off dramatically
- More likely in less secure nations, such as US (high health bankrupcies, high prison population, low feelings of security)
- Religion is strongly correlated with large groups; smaller tribes just don’t need it.
- Belief in god isn’t important, playing along with group is. EG:
- limited grasp of important religious precepts, ignorance of holy texts
- ease of ignoring basic codes when impractical (churchgoing stats in US, “believing in belief”)
- afterlife more common than god
- emphasis on community and communal ritual, instead of private prayer
- the highly religious are treated with disdain, like the non-believers
- wait, what role do true believers play? They make it easier to accept tribal markers, but also raise the bar for the rest; thus a love-hate relationship (“I wish I felt what they did”).
 Early drafts used the word “tribalism,” but I found a lot of people took me to task for promoting discrimination against “less advanced” people. I struggled to think of a better name, but even “classism” carried an implication of discrimination. Then it hit me: there is no name for this which is free of discrimination, because by its very nature it is group-based discrimination, no more or less. It isn’t fair to say we were born and bred to discriminate, but it is fair to say all of us have that capacity built-in at the lowest possible level.
[HJH of the FUTURE: I’ve since seen “groupiness” tossed around in the scientific literature.]
 “Human groups and social categories: studies in social psychology,” pg. 91-104, Henri Tajfel, 1981.
 24 different genes have been associated with skin colour, and genetalia come in even more varieties; see here for illustrations: http://intersexroadshow.blogspot.ca/2011/04/intersex-genitalia-illustrated-and.html
156 Pew Forum, “U.S. Religious Landscape Survey, 2007.”
 Lincoln, C. Eric, and Lawrence H. Mamiya. The Black church in the African American experience. Duke University Press Books, 1990.