Having kids (with the right partner and good intentions as a parent) is a great way to avoid feeling lonely.
The kid(s) are tremendous source of connection. You may trade for a feeling of exhaustion, overwhelming responsibility, etc. but a lot less loneliness.
Also go a step further and join support groups for parents. Community resources where kids play and parents can hang out and chat. Connection is built through shared experiences, and parenting is an experience you can share with other parents.
Between having kids and participating in events with other parents, there will be a lot less opportunities to feel lonely.
I think you’ve missed a step here. How are lonely and alone people, who have trouble finding friends, supposed to find a spouse and have kids?