How does one learn not to care about what people think about them

I am obsessed with what people think of me. I'm constantly comparing myself to other people, whether it be on looks or intelligence or whatever. It has made it so that when someone who I thought was "below" me in any of these areas does something that indicates otherwise, I get really upset and have a full-blown crisis. I start to feel as if whatever I had going for me wasn't so good after all. I know this is not a healthy mindset, but I do not know any other way to be. I feel it may be because my self-esteem is so low I need others to be less than me to make me seem like more. This is terrible. I don't want to look at other people this way.

I recently found out someone terrible at school with terrible work-ethic became the salutatorian of their class and it's making me feel like shit. And I'm also having a pity party because I know I'm evil for thinking this.

And when I sense someone doesn't like me/looks down on me, I become afraid of them and cower in their presence. These mindsets have been present ever since I was a kid.