There's more than one side here. Yes, Microsoft or any other company should fire the foreign workers first when possible. But realistically, it doesn't always work that way.
Say Microsoft has one team working on some craptacular product, say Microsoft Songsmith, that isn't as complex or demanding as another product, say Windows 7. Say they decide to lay off some workers. The Songsmith guys are the obvious choice, as the product royally blows to start with, but wait, we need to fire the foreign workers first. However some of the Songsmith guys aren't foreign workers. Do you take some foreign workers, who are actively involved in the production of Windows 7, and replace them with some of the American geniuses behind Microsoft Songsmith? Or do you just can everyone responsible for that crapfest?
Remember, the companies in question are large. They have many departments and projects, and the skills that make one perfect for one project may not be adequate for another. Thus, they're likely to wipe out all those working on a product, rather than simply removing the foreign workers.
Granted, in the current economic climate, Microsoft should NOT be hiring new foreign workers. However shuffling workers between projects would in order to fire the foreign workers first would be devastating to productivity to say the least.