What you are talking about is PERM. That's a requirement that the department of labor has established. When you want to hire an immigrant permanently, DOL requires that you take out an ad in a Sunday newspaper. It benefits the lawyers and the government greatly as this is a good source of revenue for both of them. As far as the actual job goes, that job was never open. The person is already working for the company on a visa. DOL just makes them do this dog and pony show before they can hire them permanently. These regulations are a few decades old and were never updated.
There are other precautions: the job application has to be mailed to a physical address and can easily get "lost", the requirements for the position are numerous and peculiar (the #1 in the old times used to be fluency in a foreign language, but DOL/USCIS eventually got tired of that one, still, since the requirements are for a particular person, it can be any random mix of skills, all of which are hard requirements), and the interview process itself is not designed to pass anyone as the person, on whose behalf the PERM is being filed, won't be interviewing. One would be spending time much more productively applying to real vacancies. The only winning play here is to go through the process and sue the company to get some pain and suffering judgment, which I have not heard being successfully done (but I don't really follow this closely so I could be just ignorant).
No expert on this, but in my estimation the nature of the law and process makes it hard to sue unless you're a one-to-one match with the job posting or invented part of the tech stack being used. Companies across various industries pass up on qualified people every day.