ranmankablam
It sounds like you've not got some social skills developed that others have but also you're struggling with understanding why people react to whatever it is you've done. Your options are essentially what Ross has said or some very heavy self-discovery at the 'social creature' level. if you have to even try and run engagements through your head and pinpoint when/what/why the tone shifts.
I'm not necessarily the best either but thats the way i've been handling it and (hopefully) improving. It is of course painful when you say/do something and realise it was a fuck up. Depending on what it is often times its not something the average person will find as dire as you do in that moment.
It's not necessarily your fault in every case but if you're looking at figuring out how to fit in or get along with people more generally you've gotta be able to take a good look at yourself. Best of luck of course, everyone decent is just doing their own version of the best they can.