Its seems like you have a desire to feel better than other people, particularly those different from you. I have problems with this too and its probably pretty common among most people. It can be a pretty difficult urge to fight sometimes, I know I fuck up all the time and get angry or frustrated by people when they do something that seems dumb or silly to me.
Ultimately nobody really chooses who they're born as and the environment that led them to be who they are, and its best to try and not think of anyone as being a worse person than you, including the worst people. Learn to forgive other people for being different or bad (obviously don't let them take advantage of this). Apologize if you've been unfair to them. Try and catch yourself when you realize that you're trying to be better than somebody else and instead try to empathize with them. Understand that they're a person just like you.
And of course, make sure that you also forgive yourself when you make the mistake of being judgmental or egotistical. Its a pretty natural human response and I myself still judge and lose my temper at people all the time even though I know its not good for me. You're a human being with flaws and that's okay.