I know of many residents who left a residency to pursue another one. I am not aware of any residency firing or forcing a resignation of a resident in any regular manner.
The advantages of employing a resident are not just about the Medicare money. It's about the free labor. The fact is that residents are far more cost effective than an advanced care practiotioner (e.g. NP, PA) in your typical hospital setting.
Hospitals get money for having a resident to do the grunt work; factor in salary and other administrative things, the hospital may make a little money, lose a little money, or break even: the numbers aren't clear. On the other hand, you need to pay a PA or NP a handsome salary for the same work. The choice is obvious to any hospital administrator.
But I do agree that there are many subpar residencies who do not look out for their residents simply because they think they can get away with it. If residents report their own residencies for inhospitable work conditions, violation of work-hours and such, they put their own jobs on the line and risk becoming orphan residents who will have to find another hospital to pick them up. Look at what's happening to the University of New Mexico neurosurgery program. They're scrambling to find advanced care practitioners for all the neurosurgery residents they're losing.
I actually know multiple residents that were fired or non-renewed from a few programs, many of which most people wouldn't call "subpar residencies". It definitely happens, but I agree that it's generally uncommon. All of the residents had deficiencies of some kind, but to be completely honest, different programs have different thresholds for remediation and dismissal, and a lot of those people went to other programs, sometimes in the same specialty and did fine.
Also the degree to which a single dismissal a year costs a residency is pretty dependent on the program. The biggest offender program that I'm closely aware of simply spreads the extra call, night float, patients, and work across the remaining residents, and the chiefs absorb the rest if schedules/duty hrs don't allow it. It basically sucks for the other residents, but the attendings, department, and certainly the hospital don't feel it at all.
I will say that Medicare pays a lot more than $60k/yr for residency spots. If you include the unallocated money given, its closer to $160k/yr per resident to support the infrastructure. For some bigger institutions, they already exceed their cap, so they get a bit less.
Completely closing a program is very different than firing one resident. You're absolutely right that a program completely closing will spend much more paying midlevels and new-hires to replace the work of their residents.
I'm saying all this not to imply that it's very common for programs to drop residents, but simply that it's not particularly rare either. Your experience will vary highly depending on your specific program, not even just your hospital/university.
The best advice I can give to everyone is to try and get along with everyone, don't lie, do your work, communicate with those around you, and adjust to the culture of your program or team as much as possible.