If residents are just cheaper doctors, then hospitals would optimize for a high resident:attending ratio.
So what is it? As far as I know, in hospitals residents are really cost effective doctors. Yes, sure, they don't do the big fancy operations, but they are very capable.
It might be that hospitals have other parameters to factor in. Maybe if there would be too many residents compared to regular doctors, people would flock to other hospitals. And so on.