The Impact of Retaining a Mortgage in Retirement
Many investors look at the historic returns of assets like U.S. stocks, compare these to the often lower interest expense of a mortgage, and conclude that they should hold on to their mortgage for as long as possible in order to invest. While this can be a viable strategy, it certainly increases risk for retirees.
According to Investopedia, leverage "refers to the use of debt (borrowed funds) to amplify returns from an investment or project." As such, carrying a mortgage to invest more in one's portfolio is a classic example of leverage.
By amplifying returns, leverage makes the good times better, but it also makes the bad times worse.
While this is true for all investors, it's a bigger problem for retirees who are dependent on their portfolios for income because they don't have time to let their portfolio recover. Poor returns and/or a poor sequence of returns can harm them very much. By contrast, an investor who is 20 years from retirement has significant time to 'bounce back' from a period of bad portfolio performance.
To illustrate how retaining a mortgage in retirement increases risk, I'll assume that a retiree in the year 2000 had a 30 year mortgage with a $100,000 balance that was paid for by a $100,000 investment portfolio. I'll assume that the average mortgage interest rate was 5%* and there was no private mortgage insurance, resulting in a principal and interest payment of $537 per month that was not indexed to inflation (i.e., nominal, not real dollars). The investment portfolio was composed of 60% in global stocks and 40% in U.S. bonds, and, for the sake of simplicity, I'll ignore the impact of taxes (i.e., deducting mortgage interest and portfolio gains/withdrawals).

At the end of June, 2023, the portfolio would have only $9,211 remaining, a mere 17 months of mortgage payments. This means the portfolio will run out of funds long before the mortgage can even be repaid; the portfolio would need to survive longer than the mortgage term for the investor to come out ahead by having kept the mortgage rather than paying it off initially. In this situation, retaining the mortgage to invest the funds instead would have led to a much worse outcome than paying off the mortgage before retiring.
*(Mortgage rates were actually averaging about 8% in the year 2000, but the mortgage could have been refinanced to lower rates along the way. Average rates didn't drop below 5% until late 2009 and averaged about 4% from 2012 until about 2020, so 5% appears to be a conservative fixed rate for this purpose. Also, note that refinancing costs would have had to be paid as well.)
Now, as is often the case with personal finance, there is an exception. If you can earn a higher after-tax yield on U.S. Treasury bonds than your after-tax mortgage interest rate, and you hold enough such bonds that are duration-matched to your mortgage to cover your mortgage payment, then that represents guaranteed arbitrage. Some investors are now in a position to be able to achieve this as they have a mortgage that they took out when rates were 2-3%, and 10 year Treasuries are currently paying about 4% before taxes, so there is potential for some interest rate arbitrage, though investing the funds in anything other than nominal government bonds introduces the risk of underperforming the mortgage interest rate.
Also, using funds to pay off a mortgage early may increase risk for those who are in the early stages of accumulation. If such investors use savings that they would otherwise have invested in stocks to instead pay off a mortgage and redirect those future savings to stocks afterward, they are compressing their stock exposure to a shorter period of time, thereby increasing their exposure to sequence of returns risk.
Investors who attempting to reduce their exposure to return risk and sequence of returns risk would do well to have their mortgage paid off by the time they retire. This helps to maintain more consistent exposure to stocks while accumulating and reduces the risks of leverage in retirement.
This is not to say that carrying a mortgage into retirement is necessarily bad. It's just that such a strategy increases both upside potential and downside risk, and investors considering such a move should plan accordingly.