How about the cases where those being replaced have to train their H1-B replacements? Their skills and knowledge are good enough to teach the job but not enough to actually do it?
I am a foreigner in this exact case. The developers who got fired needed to train me to replace them. Why? Because of the fucking mess they did here. You better have them walk you through the code and tell you where the bodies are buried. After that, I started refactoring the codebase untangling the crazy spaghetti they've created over the last 5 years, adding tests, set up continuous integration and change the way the project is managed from pretending-to-be-agile to actually-doing-the-right-thing agile. These things make life easier for me and hopefully for whoever is gonna work on this project in future.
Do I feel bad for these guys being fired? Yes.
Did they deserve it? Yes and no. They needed guidance, but the business needed results. I hope they get a chance to improve at their next job.
Lead me not into temptation... I can find it myself.