The key is Net Present Value, the value of all future cash flows, negative and positive, discounted to the present. Lots of ways to calculate, easiest instrument is Excel. You do have to do some guessing on interest rates, but easy to calculate with different interest rate scenarios.
For the "paying your mortgage off is terrible if < current interest rate", it depends.
Calculate the NPV of the investment income without mortgage payoff, and then the additional $$ to invest with mortgage payoff until retirement and see which is greatest. I had a CFO who refinanced his house for 2 months to save an extra $1K; I wouldn't have bothered, but to paraphrase Samuel L. Jackson in Jackie Brown, this guy live to f with the banks. Even wanted to be buried face down so BofA could kiss his a**.
For folks who borrowed a few years ago (3%), the NPV may well favor keeping the mortgage and investing. But, plug it in and see.
Do it with different returns on market index funds; include 1970-1980, 1980-1990, 1990-2000, 2000-2010, 2010-2021 (Covid), 2021-date.
Make sure you use inflation adjusted returns, not gross returns. The charts that the financial advisors show you rarely take inflation into account.
Anyway, from the first day of Finance: If you remember nothing else, remember this:
1.Cash is King (you can invest cash)
2.More cash is better than less cash (ditto)
3.Cash now is better than cash later (guessed it, same)
As for the Cash:Equity balance as you near retirement, that's a crapshoot. Retire in 2007 or 2019 with a heavy balance in equity? Better have cash on hand.
Young folks, heavy on Equities is good, and please, low-load index funds, (you can wait out a bear market); as you age, more emphasis on cash.
As for Dave Ramsey, rarely heard him, and he is likely OK for those with no self-control. Not many of those here; we have fancy scopes, duds, and shootin' irons. Doubt many of us have depleted retirement accounts.
I previously promoted a HS finance class as a requirement, including a discussion of student loans, and ROI for different majors at different institutions, but with some states waiving requirements to read or write, I'm not hopeful.