It's all a bit of a mix of the situation we are born into, our childhood experiences, our intelligence, our personality, our physical health and sheer, dumb luck.
BUT here's the rub. While some people have had shit shower after shit shower (my life included, right from the start all the way into my mid-30s, when I finally decided to change my luck - the shit still keeps flying hard, but I have made new choices and a much improved life) and others don't, eventually there comes a point in life where the bad childhood experiences excuse just doesn't cut it anymore.
We are extremely lucky to live in an age where we have all the material needed to help us improve our lot is a few key hits away. And yes, I include everyone in that - if you don't have a computer/ tablet/ phone, there are free computers in libraries. If you can't read, there are videos to help you do just that. We can learn skills we weren't taught at home or at school, and there is always free material available to do that. We can access therapeutic materials, even if actual therapy is too expensive. Financial advice is out there for free. Forums like MN help people gain insights beyond their echo chambers. Online gaming/ WFH etc has been a game changer for people who are isolated, be it socially or due to physical disabilities.
There comes a time in life where you have to start taking responsibility yourself and build up a cushioning against the stuff life will throw at you on occasion. Where you have to make a decision and the outcome will affect how you can deal with future adversity. How you make that decision - well, there is a world of advice out there, ready for the taking.
I know a person who has minor ailments and is miserable, and another who is at least 50% wheelchair-bound and one of the happiest people I know. At their ages, they have chosen to deal with their lot very differently, and at the age of 50+ that's not to do with childhood trauma anymore, but with informed choices. One is becoming more and more reclusive and bitter, while the other is actively researching ways to enjoy life despite her disability. Both have had the same opportunities and similar levels of intelligence and skills. But they choose to deal with life very differently.