Generally it's simple math, if you have a typical mortgage rate between say 3% and 4.5% you're comparing that to an "average" stock return. For the S&P over the last 90 years the avg annualized return is 9.8%
To be more modest, since 1957 it has averaged about 8%. Source:
https://www.investopedia.com/ask/answers/042415/what-average-annual-return-sp-500.asp
People hate the way debt feels and I don't blame them. But if you're looking at the return, it becomes very obvious in a big hurry that you lose money in the long term by paying off your low-interest mortgage rather than getting over double that in the market.
TIME is what people fail to take into account when they think about these things. They go, "Oh see? Look at that the market is way down, pretty smart paying down my mortgage now, huh?" Well no, not really. You could be getting great stock at a discount, I got like 20-30% returns my first years of having a 401K in 2009 and 2010.
If you compare the performance of your money over the 30-year life of that mortgage, the ROI on stocks is going to destroy the savings from paying down the debt.
And it doesn't really start getting impressive until that last decade. Play around with these to get a basic idea of what a drastic difference the difference between 3.5% and 8% is over 30 years. You plunk in $1,000 to start and then kick in $100 a month let's say. Roughly what you might expect the amount to be if you're deciding between an extra mortgage payment or something else.
You lose almost $100,000.00 over 30 years being at 3.5% compared to 8%.
https://www.nerdwallet.com/banking/calculator/compound-interest-calculator