Having worked in Silicon Valley for thirty years, I d like to add a couple observations. I still have to earn a living. Most of my work colleagues are foreign engineers in the situation I describe. There are many trained US engineers available whose only sin is being over fifty.
Companies favor younger foreign engineers.
They are cheaper. And because they need a green card to work in the US, the company as their sponsor has enormous power over them. During the Cold War, the US government sponsored higher education through loans, military schools, and state colleges. This sponsorship, and Cold War technical research, is the basis for the current technical revolution. The Internet itself is an offshoot of Defense Department research to build a secure communications network.