You will never make more interest on an investment than you will get charged interest for the same amount as a loan.
The historical S&P500 average is 11.88% annualised. Unless your interest rate is above this, you’re better off investing. In reality it’s more complex as there are tax considerations, liquidity, risk, opportunity cost etc to calculate. If your interest rate approaches this, paying down debt is indeed the best course of action.
My condolences.