Once you're no longer living paycheck to paycheck, you often face a big choice: Do you start investing or pay off debt first?

Eliminating debt saves money on interest and eventually frees up cash. But there's a huge opportunity cost when you delay investing until you're debt-free.

If you're 25 and you start investing $500 a month now, you'd have nearly $1.24 million by age 65 if you earned 7% returns. Wait until 35 to start making that $500 monthly investment and your nest egg would be just over $589,000 when you're 65.

Paying off debt before you invest sometimes make sense, particularly if you're paying exorbitant interest rates. But here are five times you should go forth and invest, even when you have debt.

A cartoon depiction of a scale with time on one side and a dollar coin on the other.

Image source: Getty Images

1. You get a 401(k) match.

You can't afford not to take advantage of an employer's 401(k) match, assuming that doing so won't put you behind on bills. Even a 25% or 50% match is still a 25% or 50% return on your investment.

2. The APR on your debt is below 8%.

Investing is logical when you expect to earn more than you're paying in interest. Over the past 30 years, S&P 500 annualized returns have averaged around 8% after inflation. So as a rule of thumb, you should invest only if you've tackled debts at 8% or higher.

If you have credit card debt, investing probably won't make sense. The average credit card APR for people who carry a balance is a staggering 16.61%. But if you have a 3% mortgage or a 4% student loan, go ahead and invest.

3. You're prepared for an emergency.

Having liquid savings cushions you from stock market crashes and corrections because you'll avoid having to sell when your investments are down. If your emergency fund could cover your essentials including minimum debt payments for three to six months, it's a sign that you're ready to invest.

If your savings is lacking, consider splitting the extra money in your budget between your debt and emergency fund. You're building up that rainy-day fund while simultaneously lowering the amount you need in it.

4. You're not shopping for a mortgage.

If you're not going mortgage shopping anytime soon, you don't need to worry about nitpicky underwriting ratios.

But doubling down on debt in the short term instead of investing could help you if you're planning to apply for a mortgage soon. Lenders often look for a back-end ratio below 36%. That means they want to see that debt payments, including your mortgage, won't eat up more than 36% of your budget. 

This number only matters if you're in the homebuying process. Otherwise, it shouldn't affect your decision to invest vs. pay off debt.

5. You have good credit.

A good credit score signals that you're managing your debt well. If that's the case, you can probably afford to invest.

If you have poor credit, paying down debt will help improve your score by lowering your credit utilization ratio. Boosting your score will pay off because you'll pay lower interest rates, which will eventually free up cash for you to invest.

What Do the Numbers Tell You?

Investing vs. paying off debt really isn't that complicated of a decision. Investing is a sound choice when you can reasonably expect to earn more than your debt is costing you. If your interest rates are low and you're prepared for an emergency, you can't afford the cost of not investing.