Hypothetically, if you were a Machiavellian hiring manager:
You would also prefer a foreigner on a visa because they would have less freedom to leave the company than an equally paid employee who wasn't worried that quitting a job would risk being forced out of the country.
Also this would make the foreigner more worried about the consequences of being terminated for unsatisfactory performance.