Money is measurable, engineer quality is not. Sure with a smaller startup you could average amongst the engineers but it's an imprecise value. The million threads on leetcode and interview are proof positive engineer valuation is hard.
It's all well and good to gamble when someone else, the public, is picking up the tab.
Housing is unaffordable because tech brings high-paying jobs into regions that don't want housing growth. Whether the people coming to fill those jobs and throw those salaries around in the housing market are from India or from Wisconsin hardly matters, except that it's more comfortable for local governments to be overtly hostile to the Wisconsinites.
Accepting that premise for a moment, why would the land around Bay Area offices scale any better for Americans than for H1Bs? If the opportunities simply go to Americans, you have exactly the same geometry problem. If the Americans who refill those roles do so at higher wages, the supply-and-demand imbalance gets even worse.
So then the h1b hires will go to jobs outside the bay area, reducing pressure on housing prices in the bay area.
Tech companies have N openings in the bay area. They will fill these openings. Whether they fill the openings with people moving from India or Mississippi has zero effect on the pressure on the bay area housing market.
It's all well and good to gamble when someone else, the public, is picking up the tab.