When I first started working in technology in the 90s, it was a time of outsourcing lots of work overseas. Many large companies followed the wave of manufacturing in the 70s and 80s by many companies, including lots of semi-conductor manufacturers. I watched as a number of jobs moved overseas, though fortunately not mine.
In the early 2000s, I worked at a company as a manager, where I was involved in some of the discussions about outsourcing a lot of our IT operations to another company. It was a scary time for my friends, as the move would have left a lot of them looking for work. The CIO tried to say that many would get jobs with the outsourcing supplier, but couldn't say how many.
I commented in a meeting that it would have to be less than 100% of people for there to be any profit. That statement ensured I needed to look for a new position, which I happily did. The company didn't outsource at that point, but being involved in the discussions helped me realize how different management and workers often view the business of IT.
There was an article on when to outsource, which talks about the benefits and drawbacks. For most of the benefits, the reasons why you do this are very similar to why you might move infrastructure to the cloud. There is speed and flexibility, as well as simpler internal operations, when another organization handles those functions. The downsides are that your organization needs to manage another, and you might not have the control you desire.
The same thing you could say about the cloud.
The costs could be lower, with outsourcing or the cloud, if you can reduce unnecessary resources. That can be hard to do internally, especially as you hire staff. Each additional person might be necessary in the short term, but if when they are no longer producing a positive ROI, it can be hard to get rid of them. Consequently, with an outsourced company, often contracts dictate the staffing levels, and those contracts aren't amended or renegotiated often. That could leave you with lacking services you need or paying for those you don't.
I don't know that it's easy to decide when to outsource. My view has often been to keep some level of in-house staff, but augment them with some sort of managed service provider that can provide additional resources when you get busy. Whether this is a DBA service, like https://dallasdbas.com/, or a development effort, like Crafting Bytes, adding staff in limited quantities is often the best way to move forward.
These smaller groups also provide opportunities for some of you that might want to find a different type of employment arrangement. Usually more flexibility, a warm, friendly atmosphere, and the chance to grow with a small business.
Outsourcing might sound like a bad idea to many corporate employees, but it does provide opportunities for you. Keep working on your skills, network with others, showcase some knowledge with a blog/article/speaking slot, and you might hedge your bets in the event your employer makes a decision about outsourcing that doesn't work for you.