Living with a mental illness is challenging. You are managing both what you experience inside and how you present yourself on the outside. It’s difficult to know whether and when to trust your own perceptions. Your illness has been significant enough to damage your marriage and your work life. I don’t think what you are describing is a “borderline” issue.
I do know that medication alone isn’t enough. Medication may make it possible for you to function, but it doesn’t help you gain insight into your own behavior and other people’s reactions to you. I don’t know if people are making fun of you or if that is your perception. I don’t know if you are as good at hiding your emotions as you think you are. I don’t know if there is something you say or do that makes people so uncomfortable that they distance from you. I don’t know if you are well-loved and you can’t see it. The point is — neither do you.
You need and deserve to have a happier life, unencumbered by doubt and anxiety. Your wife loved you enough to marry you so I’m guessing that at the core you are a decent, talented guy who knows how to love but not necessarily how to express it in a way that others fully understand.
To get there, I encourage you to find a licensed therapist who can meet with you regularly to help you know yourself and who can support you in developing the social insight and skills you need to feel comfortable in the company of others. A therapist can provide you with a safe place and a sounding board to explore the issues you put in your letter.
You might also find it helpful to join a forum here at PsychCentral to talk with others who share some of your experiences and who can give you practical help and support as you heal.
I wish you well.