CS PhD is the outlier and not the norm. Most fields even in STEM its impossible to get a high paying job in the field of your thesis.
I had a friend who was a chemist but she left the field to pursue data science instead after her pharmaceutical company started even more layoffs in R+D - it seems pharma companies are more interested in intellectual property law than drug development these days.
Lots of engineering companies have positions where they value PhDs.
Will it offset the cost of not earning all those years? Probably not.
Will you get those jobs without a PhD? Probably not.