I think it was sociologist David Reisman who wrote a book called "The Lonely Crowd." We can be in a roomful of people and still feel lonely. We just don't feel a sense of connection.
As far as wanting to be with other people, but not feeling that we're worthy, or feeling that we'll be rejected, or being too shy, and so on, I think that's where therapy can play a major role. We can develop a greater sense of esteem and become less shy, for example. I used to be pathologically shy, but believe me, after years of therapy, I can talk with the best of them and even stick my neck out IRL and here in asking people to be my friends. I have had one person who has "defriended" me since I have been here, and that has bothered me, but I can see from the person's posts why that happened. All we can do is try to reach out to others. If we get rejected, and we all will at some point, then that's just part of life. Unless we take chances, then we're not going to make those connections that we desire.
If you'd like to try me out as a friend, then just read my profile and see if you're interested! I see so many people here who do say that they are lonely and there's even a group for lonely people.