It's not like the options are write software or starve. Billions of people find jobs and can feed their families without writing software.
I also don't often meet junior software engineers who actually have families to feed. Most juniors work in the industry for a few years before deciding to get married and have kids.
At that point they won't be software engineers
A very small fraction of people who get math degrees actually continue to do math in their careers. They usually have to get other jobs in order to survive (actuary, teacher, finance, etc.). Academic math funding was already drying up for last few years, and now AI will probably cause more cuts. Not to mention that academic math positions have never paid particularly well.
I feel bad for anyone who can't find a job, but the software industry as a whole has been the cushiest industry for decades, and the current turbulence seems more temporary (and driven by corporate greed) than a systematic destruction of the trade.
Unfortunately this often means moving away from family. What are you going to say to the kid whose parents toiled to get him through college on the expectation that he would be able to take care of them? "Sorry Mom, I have to move to North Dakota to work on the oilfields"?