What are you talking about? Residents earn a salary (just google "XYZ university resident salary" to find it...). Medical school (which is prior to residency) is where the debt gets heaped on.
I suppose it depends on where you study. If you're at a school (a school based hospital), you pay to go. You might get a stipend, but I know people from NYU who have had to pay to attend residency.
I don't know the most about this field and you're right, a bunch of hospitals do pay. That's cool.