In very many cases, there are local workers to fill the need... but the companies are not willing to pay market rates. So they want to import foreign workers who will take a much lower salary. This has gone on for 20 years. https://www.infoworld.com/article/3004501/proof-that-h-1b-vi...
And in the medical industry, if there is a shortage of local doctors, it again likely means that salaries are depressed such that locals find it not worth the pay to do the job. So (highly educated) medical professionals from abroad are welcomed, as they will work hard for less money. If the the standard of living in India were the same as the US, they would not be willing to come here to earn less.
I do not suggest "throwing the doors open" to poor uneducated people. I suggest paying the local market rate for workers and hiring local workers. Those "non-existent" local workers would exist if the pay were appropriate for the work. It would not be necessary to import people.
I don't object to immigration in principle, but when it is used as a way to extract more labor for lower cost, also at the cost of local citizens having fewer job options and more competition, then I do disagree.
Many of the legal immigrants you speak of would not have been allowed to immigrate here were it not for heavy lobbying pressure from large corporations seeking cheaper workers. They created an artificial demand. And I don't believe in the policy of "well it's been that way for a long time, so it should persist". We should frequently re-evaluate our laws and our needs. If that means an immigrant needs to go back home, then so be it. I as an American who immigrated to the Netherlands must jump through hoops and pay not insignificant money to maintain or modify my work visa. And if circumstances in the Netherlands change such that there is an oversupply of tech workers, then I recognize that my opportunity to live there may end. Me living there is a privilege, not a right. Likewise is true for legal immigrants in the US.