Several reasons come to mind including better laborers. But also politics, culturalism, tax incentives, racism, bribery. Employment law has a large share of the legal market, keeping with litigation. We should have no expectation that companies are only hiring for company profit. Employees and managers appear to be, often times, doing what's best for themselves.
Some healthy subset of companies just want to hire the best people they can get that will accept their offer, and sponsoring an h1b is a small part of the overall costs.
As another commenter mentioned you may or may not consider my experience as selection bias. So with that out of the way:
- all H1B friends I know obviously are from work; I used to work at one of the FAANGs
- these friends are in late 20s and above, so at least SDE 2 if not more senior
- you can verify at levels.fyi that 250+ TC is normal for these roles
I'm interviewing a lot for my company and I recall in the height of the hiring boom that peaked around 21, we really are throwing out 200-300 TCs for fresh graduates, Americans or not
Clearly there has to be either a shortage of the type of worker, or the Americans want a higher pay.