Most people who are way in debt don't have a math problem, they have a discipline problem,
Understanding the math must precede applying the discipline. You can be a brutally disciplined person, but without realizing that debt has costs, and deciding you don’t like those costs, you won’t have motivation to apply that discipline to getting out of debt.
And advising someone to keep their house in debt so they can gamble in the stock market... It’s really not that cut and dried. You can own your house, lose most of your income, and watch the market tank and still get by and not lose your house and equity. But if you have house debt, lose income, and watch the market tank, you’re still going to have to make that payment, or else! It comes down to risk tolerance, priorities, etc. But otherwise, yes, borrowing against your house to have money to put in the stock market is a thing.