Most tech workers wouldn't take a $40k job because they realize that's a gross undervaluing of their skillsets. It's a much smarter decision to continue applying and hope somebody recognizes your ability and pays you what your labor is worth, rather than tie up your schedule and possibly relocate to work the low-paying job. You can ask these bad-faith questions all you want, and they might be helpful for confusing and misleading people online, but I assure you, employers have thought about them more than you, and have long since found their answer.
It seems to me that you're in outright denial about companies getting cheaper labor through the H-1B system. Instead of asking these "if companies really want to save money, why don't they just x" questions, I'd ask you why Disney DID lay off hundreds of IT workers at a time and had them train their H-1B replacements who often lacked the same skill level as their predecessors if it wasn't a significant cost savings? These aren't allegations, they're reality. What was found in court wasn't that Disney isn't guilty of replacing workers, it's that they did do it and it's perfectly legal! Wages have dropped, many Americans have switched to other professions they wouldn't have otherwise, and profits for IT firms have gone through the roof due to the H-1B program. Try reading rather than theorizing all by yourself. https://www.nber.org/chapters/c13842.pdf And go tell the Disney workers they didn't really lose their jobs.
I don't normally post opinion pieces, but this is very devastating and well-researched: https://www.usatoday.com/story/opinion/2014/07/27/bill-gates...
Business executives and politicians endlessly complain that there is a "shortage" of qualified Americans and that the U.S. must admit more high-skilled guest workers to fill jobs in STEM fields: science, technology, engineering and math. This claim is echoed by everyone from President Obama and Rupert Murdoch to Mark Zuckerberg and Bill Gates.
Yet within the past month, two odd things occurred: Census reported that only one in four STEM degree holders is in a STEM job, and Microsoft announced plans to downsize its workforce by 18,000 jobs. Even so, the House is considering legislation that, like the Senate immigration bill before it, would increase to unprecedented levels the supply of high-skill guest workers and automatic green cards to foreign STEM students.
As longtime researchers of the STEM workforce and immigration who have separately done in-depth analyses on these issues, and having no self-interest in the outcomes of the legislative debate, we feel compelled to report that none of us has been able to find any credible evidence to support the IT industry's assertions of labor shortages.
...
If a shortage did exist, wages would be rising as companies tried to attract scarce workers. Instead, legislation that expanded visas for IT personnel during the 1990s has kept average wages flat over the past 16 years. Indeed, guest workers have become the predominant source of new hires in these fields.