Are there legal ways to be hired as remote worker for a company that only has operations in the US and live/work from another country?
Edit: As a Non-Us citizen.
One option is sole proprietor as a contractor. No benefits. Pay for your own equipment, office, telecom. Do your own payroll deductions. Ask for more comp in return.
As an independent contractor the client does not create a tax nexus in your country.
As a general rule, US immigration does not come into play for employment outside the US even if the foreign-based worker is an employee of the US company. Regarding employment abroad by US citizens, that will depend in part on the laws of the country where the US citizen is residing and tax treaties between the US and that country.