I was bullied throughout elementary and middle school, but usually had one or two other kids that I could rely on to not be shitty.
I don't think that I considered the why of it until middle school, but at that point I started to put a lot of value in my intellect and saw that as a distinguishing factor without being able to see any of the social deficiencies that I obviously would have been demonstrating to everyone.
Of course, telling yourself that you're more intelligent than your peers is a cope even if it might be true. Relative judgements of others are ego soothing, and anything that allows you to feel superior can cause you to overlook what you are lacking or can suppress your insecurities.
For a long time, once I became an adult and realized that my intellect did not afford me what I desperately wanted in life (to get along with others and be accepted), I simply felt that I was fundamentally and irredeemably flawed as a person.
Pretty good self esteem now, though, and I don't rely on petty judgments of others or any idea of superiority to support that.