Paying down debt reduces future interest as set by the contract. Investing has an uncertain result and keeps the money exposed to losses. To compare, use the same amount and time frame.
An example with numbers
In a one-year example with debt at 4%, no fees and the balance outstanding for the whole period, paying down $5,000 at the start avoids $200 of interest. A $5,000 investment would need to earn that $200 after costs to match the saving.
Try it with your numbers
Write down three possible investment results, including a negative one. Compare them with the contractual saving and with the cash you would keep for emergencies.
This calculator is on its way. In the meantime, you can do the calculation on paper or in a spreadsheet.
Example figures for learning purposes. They are not a recommendation and do not replace professional advice.