You may be thinking about your unique situation.
We have a few PhDs as engineers, one of which is my friend. He was indeed outsourced a year ago. (He took a job within five miles of his home for a higher salary.)
Not all PhDs are filling PhD positions (particularly engineers) and all it takes is a pen to change the job description.
We employ a fair number of mathematic PhDs but their degree is not essential to the job. Despite only having a pedestrian bachelor the PhDs are peers.
Depending on a company's motivation to outsource the bottom line often seems to drive who's on the chopping block. Not their skill set, degree, or contribution to the organization.
Btw I've never found a 1:1 relationship between the output of an outsource resource to the original employee. Never.
Edit: actually I take that back. I can think of one person outsourced and the off shore resource was better. Unfortunately the new resource isn't much benefit to my team because he only needs to do the minimal amount of work because that's all the original employee could do. Lol.
The h1b issue is caused by short sightedness by management and by complacency by employees.
I can't be replaced by an h1b because it takes 3-4 of them to do my work. I'm what is known as a "purple squirrel". My wife likewise. Plus we have enough common sense to detect outsourcing and act accordingly if needed (her, not me).
Now, I don't expect the average common mortal to go and get a PhD to avoid being outsourced, but it takes some effort to learn new things and stay current. In engineering, it's expected and generally done. In IT... not so much.
Or, if you end up in a small town with few options, because you love the rural lifestyle, well, tough luck...
Having said that, the current crop of h1bs is generally awful. Nothing like the top people from decades ago. And I hope Trump does something about it, but will believe it when I see it.