And since you're talking about software startup employees, probably the closest comparison is CS phd students, who are nowhere near suffering. The vast majority of graduate students are at least as satisfied as a developer, otherwise whole programs would have disappeared decades ago from inability to recruit. New admits always ask current graduate students what it's like. There seems to be this dissonance between people here on Hacker News believing that everything is like the horror stories of grad students being abused by psychopathic advisors and at best will get poorly paid adjunct positions before burning out, and what's really happening.
All of which is to say, grad school is horrible. Sometimes. Sometimes it's awesome, and YMMV.
The US takes 1.2 million immigrants a year, but it is extremely difficult to gain admission as a random applicant without family connections.
One possible way for in is graduate degrees in STEM fields. There are various work visa programs that are far easier to access through STEM graduate school in the US. You can get here on a student visa, gain some connections, interview on campus, and perhaps get a work visa through a tech employer - and this is easier with a grad degree, as those degrees grant certain exemptions from visa caps. If you remain in the good graces of your employer or university, you may eventually qualify for a green card.
It's a slog, but keep in mind, we're not talking about people with freedom of choice here. It might be more rational to sell real estate, open a sandwich shop, or become a dental hygienist if you were allowed to do so legally without fear of deportation.
But if your options are very limited due to visa and immigration restrictions? Sure, it can be highly rational to pursue a graduate degree in a narrow subsection of STEM fields. Unfortunately, as long as universities have this power, they probably won't have much incentive to make the degrees rational for people with the freedom to choose their careers.