Mind you. Companies can do more with internal development/retraining and institutional knowledge is a thing especially with large organizations. But, at some point, no one's going to be happy.
I remember, many years ago, being tasked with teaching PHP to the mainframe COBOL team - we’d retired the mainframe, and all our COBOL apps with it, but we’d kept the team, and management had struggled with finding them something else to do. It was a painful experience, they were getting it, but very slowly. Didn’t help that I wasn’t the best teacher, I had to slow myself down a lot and found that a struggle - but I was young and inclined to say “Yes” to everything.
Eventually, they were all laid-off - and pretty much straight-away found new COBOL jobs (with a higher salary too). I think, in the end, they were happier that way.
And it's also possible they were actually high performing in their last role but they managed to bruise someone's ego and wound up first on the layoff list as a result.
There is just way more to firings and layoffs than performance.