I know you've mentioned that you are shy, are you aware that shyness can come across as stand-offishness sometimes? I'm not saying that's how you come across as I've never met you, but it might be that the way you behave is not perceived by others in the way you expect.
Can you give a couple of examples of things people have said to you that you've found hurtful?
About 10 years ago, I had a major friendship epiphany. I felt a bit like you, that people weren't nice to me, and I think actually it was something I created for myself. I actively sought to give off a 'don't mess with me' sort of vibe to protect myself from inner feelings of shyness and not being good enough/interesting enough - the result was that people thought I could 'take it' if they were abrasive with me. I think a lot of the time, you get what you give.
I made a lot of changes after a period of feeling very low and lonely and disappointed with the people in my life - things did turn around but it takes time. I now consider myself 'popular' (sounds a bit big-headed and when you write it down...) in the sense that I have lots of friends and get lots of social invitations - the diary is pretty full. But I still have probably 2 friends that I can truly rely on, and not many more that I would ask a favour from.
People are much nicer to me generally now, and I have lowered my expectations and my emotional investment in the wider social group. For 'funtimes' friends, I try to: be more positive than negative, ask them about their lives/how things are with them, be open and smile and continue the conversation if someone initiates a conversation with me (whether a friend or stranger), turn up to social events (those who can be relied on to turn up are the ones who get invited first - nobody likes rejection), and initiate social events myself (can be hard work and people are usually fairly unappreciative but it can encourage others to arrange stuff and help you form stronger friendships). I don't take things personally and I don't dwell on stuff.
It is not nice to realise that most people's friendship is superficial, but once you accept it you will be much happier. If you do have some true genuine friends, be thankful and prioritise those people - you are lucky, some people have no genuine friends. And a lot of people don't know the difference between superficially 'nicey nicey' folk ("oh do you know X, she's soooooooooooo nice" - when they really mean "X smiles a lot and is all bubbly and fun but underneath the veneer, doesn't give a shit"
) and those who would be right there if you needed them.