As
@Agamemnon Busmalis said, if you would make more money by not paying off the debt then don't pay it off.
Take student loans for example. Let's assume that you got unlucky and took out $10,000 of student loans when the interest rates on those peaked in 2018 at 5.05%. In the intervening years you've saved up $10,000 in cash. Now that repayments have started up again, you have two options:
1. Pay off the balance as quickly as possible so you pay as little interest as possible.
2. Wait it out and pay $106/mo for the next 10 years.
Emotionally, you're going to want to choose option 1. Get that monthly payment out of your life and stop paying interest. Over the course of 10 years, you'll end up paying $12,757 on that original loan.
However, financially it makes more sense to invest. If you take your $10k that you've saved up and stick it in something like SPY or a similarly safe, boring, low-yield ETF then after that same 10 years your $10,000 would be $30,000 ($23,000 if you adjust for average inflation).
The same thing applies to paying off any debts. If you can get a higher return from investing than the debt costs you, then invest. If you can't, then pay it off early.
Mortgage? Invest, unless you have an 11% interest rate or some insane shit like that, in which case refinance it.
Auto loan? Depends. Average auto loan across all credit scores right now is 6.6% for a new car and 11.4% for a used car. If you're closer to that 6.6% it's likely better to invest.
Credit card? Pay that shit off. Average interest rate on a new card is 24.6% a year, and the only way you're gonna beat that is by gambling on stocks and/or shitcoins.