It's not $250k in spending, it's $250k in investing. Because, IF you manage to complete it, do well, AND find a job afterwards, it will most likely pay more than $40k allowing you to pay the loan back quickly, plus, it will generally, be much more profitable in the long run.
I agree it's a very risky investment though. Nobody said math was easy or did not take tons of hard work and determination. The competition is fierce and there's no guarantee that you will succeed, no matter how hard you try. That's why most people don't start a PhD with no funding at all. This is true even in Europe where most universities have low (to non-existent) fees (for EU citizens at least).