Image: Money Puzzle © Glowimages, Getty Images

A lot of advice about paying off debt encourages a laser-like focus. Debt is expensive, while investment returns are uncertain. Who wouldn't choose to pay off a credit card charging 22% instead of funding a retirement account that might return 8% (maybe, if you're lucky)?

So, case closed, right? Not so fast.

Too many people making the debt vs. investing analysis are missing the bigger picture. And if they knew exactly what they were missing, they would understand the correct answer is: Do both.

Here's why: Retirement is expensive, and it can last a long time. Most people will have to save a substantial portion of their earnings over their working lifetimes if they want to retire comfortably. If they don't take the opportunities they're given to invest for retirement, they quickly fall behind, never to catch up.

More specifically, here's what you lose when you don't invest for retirement:

A possible company match. Most companies that offer 401k plans also offer some kind of match -- typically half of what you contribute, up to 6% or so. That's free money, honey, and represents an instant 50% return. Even smaller matches can give your account a substantial boost.

Image: Liz Weston

Liz Weston

A tax break. When you put a dollar into a retirement plan, you get to invest the whole dollar. If you want to put the same dollar toward your debt, however, you'll typically have only 85 cents to work with if you're in the 15% federal tax bracket -- and even less if you're in a higher bracket. Lower-income people could be giving up even more: a tax credit that can equal up to 50% of your contribution.

The power of compounding. It's been called the eighth wonder of the world, for good reason. It can make you rich if you understand how it works.

The best way to illustrate its power is through the example of twins Megan and Morgan. Megan invests $250 a month, or $3,000 a year, in an IRA starting at age 22. Morgan procrastinates. At age 32, Megan stops investing and Morgan starts, putting aside the same $3,000 a year and continuing for the next 30 years.

Overall, Morgan contributes a lot more to her retirement: $90,000, versus Megan's $30,000. But guess who has more money at age 62? It's Megan, the one who got the early start. Exactly how much more depends on the rate of return you use, but assuming a 7% return would leave Megan with $315,522 and Morgan with $283,382.

You may not be able to contribute $3,000 a year yet. You may not have a sister named Morgan. It doesn't matter. The point is that money contributed to your retirement accounts when you're young matters a lot more than money contributed later in life. If you put off investing for retirement, it will get harder and harder to catch up. Many people find they can't. Their expenses grow as they get older, and they can't reclaim the golden opportunity they had in their youth to assure their future comfort.

That doesn't mean it's hopeless if you've already reached midlife without much retirement savings. But you really need to start socking money away and not putting it off any longer, unless you can live on about $1,000 a month (which is the typical Social Security check).

Here's the thing: Saving for retirement is often a "use it or lose it" proposition. You can't get back the company matches or tax breaks you didn't use. You can't make up for lost opportunities to fund Roth IRAs, which probably should be called the ninth wonder of the world. (Roths don't offer an upfront tax deduction, but your contributions can be withdrawn tax-free anytime, and all your earnings are tax-free when withdrawn in retirement.) You certainly can't turn back the clock to get the returns you missed because you failed to make those contributions.

Will your investments show positive returns every year? Probably not. Some years, you'll lose money. But over time, a diversified portfolio of investments should earn the kind of returns you'll need to retire someday.

Does that mean you can ignore your debts? Hardly. What you need is a smart debt repayment plan that focuses on paying off your most toxic debt, such as credit cards, while you also save for retirement. You don't have to be in a rush to pay off low-rate, potentially tax-deductible debts such as mortgages and federal student loans. Save prepaying those obligations until all your other debts are paid off and you're on track for retirement.

Click here to become a fan of MSN Money on Facebook

What if you just can't do it? What if you can pay only the minimums on your debt, or less, if you try to save for retirement? Then you're in a deeper hole than you may understand. If you can't cut your expenses or earn more money to free up the necessary funds, then it's time to make two appointments: one with a legitimate credit counselor and another with an experienced bankruptcy attorney, to see what your options might be.

Liz Weston is the Web's most-read personal-finance writer. She is the author of several books, most recently "The 10 Commandments of Money: Survive and Thrive in the New Economy" (find it on Bing). Weston's award-winning columns appear every Monday and Thursday, exclusively on MSN Money. Join the conversation and send in your financial questions on Liz Weston's Facebook fan page.