Companies do it primarily because they don't understand the large variance in productivity between tech people, which seems to range between 18x-25x. They think they can outsource the task like outsourcing office cleaners.
The problem with that is companies can't tell how badly they are doing at recruiting. They think they are doing great, because they fill positions with people with credentials, but they can't gauge the bottom-line productivity. They can't see how badly they are doing compared to other companies. (Ironically, some companies see that when they go out of business.)
The skills needed to know how good you are at something are the same as the skills needed to be good at it. Which means if you aren't a good tech person, which HR people aren't, not only do you not find good tech people, but you also can't tell you are doing a bad job it.
Most companies are also not willing to pay to get this higher productivity. Partly because they can get away with it, and partly because they have been conditioned to believe tech salaries shouldn't vary more than salaries in other professions.