The idea is that you employ for your competency and value add, and outsource the rest. So core R&D should be in house headed by a VP of engineering, janitorial services can be outsourced not headed by a VP of cleaning the offices. In the early days, outsourcing wasn’t done, so janitors were included in those earlier Microsoft millionaires.
In a way it makes sense: you want to focus your effort on producing your product, not on the best way to clean your office. The company you outsource to can focus on that, where they make their own profit serving multiple companies. Sometimes you don’t have a choice (eg foreign companies in some countries have to contract with specific firms to do their security, they can’t have it in house).
The line gets blurry for jobs that approach the core competency of the company. So rather than janitors, should people doing grunt training classification be in house or not? Cases can be made either way, I guess. The outsourcing company probably can’t specialize in that, and they are just providing bodies at that point.
There are some weird rules about benefits that companies can only offer if they offer to all employees. So one tech company that doesn’t employ lots of its own warehouse staff (I’ll let you guess) can’t offer as good as health insurance as one that doesn’t.