I have over $400k of mortgage left at nearly 5%. I can deduct $21k of mortgage interest this year, so I'll get a discount of $7.5k.

For the life of the loan if over 30 years, I would have paid $750k in interest, $262k in discount via tax deduction, so net negative $500k from interest alone.

Inflation will devalue the principal I pay early, but doesn't it devalue the stock as well? 6% annualized return, minus the 1% annual inflation, gets me near the 5% interest rate on the mortgage.

And any realized gains on stocks get taxed at capital gains rate, so marginal discount is absolute 15% (35% top bracket vs 20% marginal rate).

I can see what you're saying, but I think the calculations aren't as favorable as you think, especially with the risk of stock devaluation in any bear market (and I understand realized vs unrealized loss in bear markets, but I'm factoring in illiquidity during those bear markets as a disincentive for loading up heavy on stocks instead of paying debts).

Hind sight is great, it could prove anyone right or wrong, but I feel safer knowing that my worst case scenario is not having as much gain in a market as someone else, but your worst case scenario might be 50% down in the market and no liquidity to invest low.