Sure, but many companies outsourcing aren't looking for the best, they are looking for the cheapest, and surprise-surprise the cheapest are not the best. Some of them are goddamn awful - close to zero value, but upper management typically never hears about that and just thinks they are saving money because they are cheap.
There is also a big difference in mindset between an employee hoping to advance their career at a company, trying to become a SME, pushing initiatives, incentivized by stock grants, actually caring about customers, etc, and a vendor employee - even a good one - to who this is just a temporary gig, and has no vested interest in the quality of the codebase or building value for the company.