Well, it's usually due to taxes. The company I work for hires people from other countries officially as contractors, otherwise they would need to maintain a legal presence in every country that they hire in - or so I'm told.
Yes, this is a difficult issue. At GitLab we have people in more than 30 countries. In the majority of countries we have contractors, in some (US/NL/UK) we have a company, in some we hire through a reseller (India/China), and in Belgium we can hire on the Dutch payroll due to the EU. I hope someone starts the Stripe/Adyen for payrolling people. If you plan to do so please email me so I can help with advise and be your first customer and investor.
Why would they not just hire people as contractors (instead of turning every non-US-resident down)? That's how I've been working for years and it's better for me as well as for the company.
EDIT I made a blog post about this https://gitlab.com/sytses/sytses.gitlab.io/commit/e9a000d321...