Outsourcing has its fair share if disadvantages. It happens a lot, mind you; not remotely every company has its own IT department, builds its own website, etc. But if it's part of your core business, you probably want some direct control over it and not be at the mercy of other companies. And that means hiring the right expertise.
Whether to outsource or not is an important strategic decision that depends on how important the task is to your core business, what kind of expertise you've got in house, and how well you can guarantee the quality of that expertise. But in the right circumstances, having this in your own company gives you more control at a lower cost than if you outsource it.
Then there's offshoring, of course, which is outsourcing to a cheaper country. This was popular 10 years ago because from a management perspective, because of the lower cost per hour, it seemed to be cheaper. But if it takes more time, you lose that advantage. Most companies have finally come to understand that offshoring means you import a big communication overhead, and you hand over quite a lot of control over the quality of the project to a party that is not always capable of delivering the quality you need. Fixing the mistakes takes a lot of time and money.