Tech firms *pretend* to not be able to find workers in the US, opting to hire foreign workers instead, for a few reasons. One is that they generally cost less. Two is that it's really, really hard for an H1B worker to change jobs, because they have to be sponsored. This gives the company essentially captive employees.
To be allowed to hire a an H1B applicant, the employer has to "prove" that they can't find any acceptable workers in the US. They do so by crafting the job description and requirements to specifically describe the H1B applicant they are trying to hire, in such a way that nobody else will qualify. It doesn't matter if all the "requirements" are really, truly required for the job, they're just checking a box to make the visa work.
They also have to publicly advertise the openings and be "unable" to find anyone qualified. They check this box by simply refusing to accept any other applicants that interview, by finding some little thing wrong as an excuse to reject them.
How do I know? I've had to jump through these exact hoops at my current company, to enable them to hire H1B developers.
One of the issues with tech jobs is that it's not simply about if you're qualified and can do the job; there is also how good are you at the skill. The 10x engineer is real; a better engineer can be highly highly more effective than a mediocre one.
The incentive for the tech companies is to hire the best candidate rather than just the qualified candidate.
This is where the issues crops up. You interview 10 people let's say and then the top choice is foreigner or H1b. Companies right now will hire the top choice and not prioritize the local candidate even though they don't rank at the top.
There is a provision in h1b where if you're qualified for a position and you see an h1b occupying it, you can take that person's job. The employer is required to give it to you. The job descriptions and requirements are all stored and archived in the DOL website. But, I have not heard of a single incidence of this happening.
If you look at Google's postings, the job description is so vague that anybody with a degree in that field can qualify. Yet nobody challenges it.
So, at least in the tech sector, it is designed to get the best candidate and then comply with whatever regulations are in place. This is perhaps not in the spirit of the law of prioritizing American workers but companies will prioritize their own productivity and do all the obligations necessary that the law requires.