> Why do companies, when they could do it in house, use them?
A few basic reasons:
* You can't do it in-house as well as a contractor who specializes in this field, or as well as this particular contractor. Very broadly speaking, the best people in field X want to work for themselves, do things their way, and keep the revenue from their work. They don't want to be several layers deep in management at your company, to have f-ng morons (i.e., anyone else) telling them how to do their job, and to be paid a salary for the breathtaking, save-the-day miracles they routinely output.
* It's not worth the investment: You would have to find and hire talent, ramp up, provide resources to them (equipment, training, etc.), be able to manage the talent in a field that isn't your expertise, and keep them busy and interested. Maybe you don't have enough scale in the things they do to support quality resources; maybe you just don't have enough work or enough interesting work for them.
* Every additional employee or capability is a distraction for the organization, including management. Keep focused on the things you do best and that are strategically important; you don't even have time for that. If you're small restaurant chain, IT isn't strategically important - it just has to be reliable and good enough. Outsource it and focus on world-beating food, service, and marketing.
* You don't want to pay benefits, taxes, or have the other responsibilities of being an employer. See: Uber.
* Sometimes it's just politics: I once worked in an outsourced capacity for a company where the IT manager simply didn't want to invest in a technology that would threaten their fiefdom, so somebody brought in a contractor. It was not a fun place to be.