Once X is widely known as a path to wealth, entry level positions get flooded with applications (e.g. a junior posting at my company could easily receive 1000 resumes) beyond what they are capable of judging on an individual basis. Once companies hit this point, they start looking for heuristics to cut down on the amount of searching they need to do. "Gatekeeping" is these heuristics.
Consider that for most top law firms, if you're not coming out of the top 3 law schools they're not interested. Why? Because those schools do a good job of filtering out bad candidates, and offer up enough good ones to fully meet the hiring needs of the company, figuring any generational geniuses they miss will make a name for themselves some other way and can be hired later.
So why does the gatekeeping all seem to help upper-middle class people? As a former educator I'm going to say it's because when it comes to the skills companies are looking for on average children of upper-middle class people are better if for no other reason than they've generally had much more money spent on their education and training, to the tune of over a million dollars compared to lower class peers.