It's needed because the private sector isn't paying for it.
There's no law that says private hospitals can't fund residency slots - in fact they fund many of them - but, as the source you're commenting on says; "[medicare is] the principal source of residency funding".
And the "private sector" is the existing physicians. Every dollar they pay a resident can't be used to buy their spouse more Prada or new tires for the Porsche. But the AMA had kept the valve throttled so long, society was desperate. Seeing a bunch of short-term greedy louts who apparently didn't study much math (don't get me started), the government seized the opportunity to pay for residencies, which created a Venturi effect where they can suck up not just the MDs, but added the flow from two other pipelines: the DOs and IMGs. And the flow has been so vigorous and steady that additional medical schools have opened outside the US borders (the Caribbean, Middle East, etc) to support the flow.