At its heart Apple is a hardware company and everything they do is to drive sales of hardware. An iOS developer is forced to have Apple hardware. They could charge for MacOS and they could charge for XCode. But they don’t because the cost of continued development of those applications is subsidized by hardware sales.
Although I see the why, the how and the need, it is entirely synthetic. In a way Apple forces this incredible waste of hardware that is never seen and could easily be virtualized and time-shared (there are no technical limitations). It's really an opposite-of-green initiative. Although, perhaps the only real alternative would be everyone buying a mac mini and use it even less (in total), which would be even less green...