It seems a lot of people are lonely these days. The reason I'm lonely is simple: I was bullied with physical violence all the way up until high school. I never learned to socialize. To this day I'm subconsciously expecting every conversation with a random stranger to end in a fist fight.
I've tried mental health professionals. They're a waste of time, and money if they try to prescribe you anything. The truth is the functional human behavior when lacking the belonging need is to feel bad. The actual definition of insanity is when a mind doesn't match the environment. If you're alone and think you're the Queen of England, see a psychiatrist. If you're alone and feel sad, your mind is adequately assessing the situation and the psychiatrist can't fix you because you aren't broke.
As for keeping yourself alive, hatred is an underrated emotion. Unlike love, you don't need another person in your life to hate. So a functional reason to live is to think of the people who set up the loneliness epidemic in the first place, realize they probably want you to commit suicide or even worse sperg out and try to take people with you in some act of violence. Hate those people and live to spite them.