I've seen some of my smartest friends stagnate to the point of being 9-10th year phds without the ability to navigate the job market. These are people at places like MIT and Caltech.
One of my regrets was turning down an offer at a FAANG to go to grad school in 2014. I finished up in 2020 and couldn't even land an interview despite having a pretty good publication/open-source track record. My advisor was no help on the job market, I felt kicked to the curb.
Took me 1 year to find a job (backend engineer) and I'm still grappling with the fact that I wasted my 20's doing a PhD when I could've at least enjoyed life a little bit more and had a bit of a financial cushion. Honestly, being a swe in industry is a vacation compared to the uncertainty and workload during the phd.
In the US, you're looking at paying $20-50k/year, and while most students will get tuition waivers and small stipends, those often disappear if you do any contracting or work on the side to supplement your meager income.
Meanwhile, $100-150k is a reasonable starting total comp right out of school, especially after the recent rash of inflation. And a good worker can realistically double that in the 4-6 years that it would take to get a PhD.
So the opportunity cost is staggering, but wait - there's more. The job market for tech positions has been very hot for the past decade, and the global economy is on the verge of a rebound. If you want to learn about a specific field like ML or aerospace, you can just get a job in that field. Kids graduating today have the option of learning from talented and driven people while earning a reasonable salary.
Research certainly has its place; most of the work that we do is based off of concepts that were pioneered decades ago. But from the perspective of a prospective student in the 2020s, it's a hard sell.
Especially since the current advisor/advisee relationship is rife with perverse incentives. This whole wall of text assumes the best case scenario, where you don't end up in a toxic lab.