Through the end of the nineteenth century it was difficult to make a living as a doctor in part because there were so many of them. Doctoring was largely unregulated, and so anyone could set themselves up as a doctor. Medical schools were mostly for-profit operations whose existence depended on providing doctors-to-be with the credentials they were willing to pay for. Professional organizations did what they could to sanction a few and ostracize the rest, but they were only locally effective, e.g. in New York City. Things were expected to change slowly if at all, due to the hands-off attitudes of state governments.
But perseverance by the AMA paid off. It managed to get licensing requirements established in all fifty states, and to get itself established as the authority by which medical schools were evaluated. Once this was accomplished, the AMA began to drastically increase the educational requirements for doctoring, from a couple of years of part-time study to eight post-high-school years of full-time study as of 1906.
The pressure was too much for commercial medical schools, who couldn’t afford to provide the staff and equipment needed to educate students according to the AMA’s standards; some failed, the rest simply lied about whether they were meeting the standards. Then in 1910 a detailed survey was done of every medical school in the U.S., demonstrating that the remaining commercial schools were lying, which forced them to close their doors.
The result was that doctors were much better trained, but there were also many fewer of them. Those who remained were much better paid; the competition which had kept them poor had been eliminated.