More often than not, it's by complete chance. There's tons of people that grow up in shitty circumstances that "have potential", and not all of them are going to live up to it. The most likely avenue is that a mentor of some kind entered the person's life (teacher, Boys & Girl's Club, etc.) that supported/push them to aim higher. Then X years later, they will feel oddly smug and say "well, if I can do it, then anyone can!" conveniently leaving out the pure luck they just happened to have.
You have a river that separates two climates. One is a barren desert, and the other is a lush forest. You have two villages on each side of this river, and they can see each other off in the distance. But the river is deep, wide, and treacherous.
So the lush village talks a lot about how lucky they are, how unlucky the other village is, and how they should recognize their luck in being born on the lush side of the river. And that's what they do.
How does this help the barren village?
It doesn't, and that's the point. The lush villagers feel as if they're morally good people because, after all, they recognize their luck!
But NONE of them take the ultimate responsibility and try build a bridge. They're content being morally good people who are lucky.
And then imagine one day a barren villager arrives in the lush village. And this villager starts talking about how they crossed the river, and others could too if they were willing to do what this particular villager did.
And the lush villagers start telling this person they're morally bad for believing others can do what they did. What about the disabled and the infirm? But really, the lush villagers just don't want to believe they could have taken the ultimate responsibility to build a bridge because it would lay bare the truth, that they're just as immoral as everyone else. That they COULD have solved the problem, or at the very least lessened the problem. But their goal was never to solve or make it better. Their goal was simply to live with themselves as the beneficiaries of that luck.
The only real difference between this analogy and what we're talking about here is that the solution isn't as clear cut.
What you basically said was "human beings who are taught the right things will be successful because they'll make better decisions in life". Which strongly implies it's not about chance because we as a society could take it upon ourselves to ensure as a society all of our young are taught the right things.
But rather than do that, people teach their children the right things, and then let themselves off the hook for all the other children by "recognizing" how unlucky they are. When they know, they KNOW, when no one is judging and they're being honest with themselves, they know they're just as large a part of the problem due to their own selfishness.
---
This problem will start getting better when these smug ass keyboard warriors stop recognizing shit and start taking action. When they stop being able to live with their own inaction and are instead pushed to action.