After thinking about it a bit, here's the way I see Comic Book Guy, based on my own intuitive understanding and experience liberally sprinkled with pop psychology:
Comic Book Guy is someone (typically male) who is somewhat introverted, reasonably intelligent, and most of all severely lacking in self-esteem and confidence. He compensates for that lack by becoming deeply invested in comic books, RPGs, or some other segment of pop culture, and then using his extreme knowledge of that area as a way to demonstrate his (self-perceived) superiority by putting down people who don't share his opinions or who lack his level of knowledge.
The thing is, this phenomenon is self-reinforcing. Comic Book Guy is so obnoxious because of his insecurities. But those insecurities are fed by his knowledge that, due to his chosen interests, the rest of the world perceives him as a geeky loser. The more the world views gaming as a haven of Comic Book Guys, the more Comic Book Guys gaming will produce, reinforcing the world's perception, and so on.
Fortunately, this does suggest at least a partial solution: Stop reinforcing the perception of gaming as the pastime of geeky losers! And by this I do not mean "don't be Comic Book Guy," because most of us aren't, so that advice is not helpful. I mean, stop talking about gamers as if we're all Comic Book Guy. Don't talk like that to the rest of the world; more importantly, don't talk like that to your fellow gamers.
This is something that I see all over the place, both online and in real life. Hell, I've done it myself. People make offhand remarks about what losers we all are, how gamers never get laid, neckbeards and fatbeards and so on and so forth... and if they get called out on it, they protest that it's all in good fun, or they're just talking about a toxic subgroup, or whatever. Which may be true, but doesn't change the fact that every one of these remarks is helping to spawn the next generation of Comic Book Guys.