From a life of nerdiness and people-watching, I have learned this:
Every superiority complex has an inferiority complex beneath it.
Arrogance is the expression of a superiority complex. It's a coping mechanism, to preserve your self-worth when you feel less than others in some way. Generally, with nerds, this inferiority complex is social. It's more difficult for most of us, and growing up you see evidence of that failing every day in school, while we huddle together with other socially-awkward nerds. But feeling inferior sucks, so we take what we're naturally good at - coding, reasoning, some technical specialty, and judge others against that, and it doesn't hurt so much. We reject them before they can reject us.
At their base, the two complexes are more alike than not. Feeling superior and inferior both separate us from others, and it's that social connection that we miss. Nerds want to be liked and accepted just like anyone else. We're social creatures.