As someone with his finger on the pulse in this industry, I think it comes down to companies motivations. In technology especially, you want the most informed, talented, passionate and competent. Or, you cost your economy potentially billions, maybe hundreds of billions in value. Someone working on a team that develops any number of applications that can be used for a consumer product, medical, patent discovery, etc, is invaluable to a company and economy. It could even apply to the military, and you don't want your enemies to have this talent.
Then, there is the ageism discrimination that is in the tech industry, Replacing, talented older workers, with younger, lower wage earners. The second part of this would be the source of many companies motivations for H1B. If companies are wanting employees only from India and China, you can bet it not the most talented, but the lowest paid.
It's ironic to me the amount of talent that is untapped is probably in Europe. Linux was create by Linus, a Finn. This O/S alone has revolutionized personal and even high performance, network computing. Python, maybe the most in demand for A.I, was developed by Rossum, from the Netherlands (who also made his mark in the U.S). The second vital language to A.I is the R language, developed in New Zealand. See the pattern here?
Bottom line, companies need talent, but you have to pay for this talent. If they want mass, low level programmers, you will achieve that by grabbing from China and India. Any great talent, especially in China; will remain n China as the government will keep them. To a lesser degree, this is true in India as well. Simply driving labour costs down would decimate many software developers in Cali, might even collapse the economies of some locales in Cali if people can't earn enough to fuel the economy there.
Europe, Canada, UK, all other locations, it's competition for the best. The best talent are mobile and have their fingers in many pies. You aren't going to find many of the above developers, any more than you would find a Gates or Jobs. However, You might find an Andrew Ng (born in UK, educated UK and USA) or others who might be a few steps behind them, who can contribute more than just cheap labour costs.