PZ Myers has offered eight fairly solid reasons for not believing in god. Here is number 8:
There are always better explanations for unexplained phenomena than god: fraud and faulty sensory perception cover most of the bases, but mostly, if I see a Madonna appear in a field to bless me, the first thing I’d suspect is brain damage. We have clumsy, sputtering, inefficient brains that are better designed for spotting rutabagas and triggering rutting behavior at the sight of a curvy buttock than they are for doing math or interpreting the abstract nature of the universe. It is a struggle to be rational and objective, and failures are not evidence for an alternative reality. Heck, we can be fooled rather easily by mere stage magicians; we don’t need to invent something as elaborate as a god to explain apparent anomalies.
I would tweak this eighth response. I don’t think most believers have a generally malfunctioning ability to perceive, and I wouldn’t attribute their willingness to believe to fraud, at least not fraud in any traditional use of that word (where intent to deceive is key).
Rather, I suspect that the elaborate hyper-sensitive cognitive machinery that allows us to detect potential allies and facilitates the formation of social bonds with them is rigged to dim the perceptual abilities of 90% of us, based on perceived threats to social relationships we value. Thus, as I see it, the perceptual machinery isn’t completely broken. Rather, it dims only when competing social cravings slap the “toxic” label on evidence that seems to be inconvenient to the formation or maintenance of a social group. This cognitive function dims our abilities to see and hear based on whether the things we might see or hear could damage treasured social relationships. It seems as though some sort of rough and ready mini-brain screens the world for our bigger better brain (at least in 90% of us). That mini rough and ready brain functions as a paranoid secretary who won’t let calls come through to the boss because the secretary is over-protective.
I discuss the connections between social cravings and inability to appreciate evidence, as well as some of the science that guides me in my views, in a series of posts I titled “Mending Fences.”
I think you've pretty much nailed it. That also explains the defensive responses to any threat to belief. If it were only a brain malfunction, correction would generally be welcomed (as it is when proofreading, for instance).
Cherished beliefs (whether religious or not) are cherished because of a status they appear to confer. That status can be belonging to a social group (as you stated), or a feeling of superiority, or a variety of other social reasons that have nothing to do with their truth or falsehood beyond their vulnerability to being debunked.