Debt is a virulent disease. It spreads. Many credit cards charge 20% interest or more. The chances that you will do better than this as a novice investor are between slim and none. To put the figures into some perspective, Warren Buffett -- arguably the world's greatest investor -- has managed an average annual return of around 22% over the last forty years.
True, some people pay only 0% rates on their cards as a result of balance transfer deals. These deals are a good idea whilst you reduce your debt. But a credit card balance is still a short-term debt, whatever the rate.
So, pay off all your debts first. However, there is no reason why you should not learn about investing in shares before you get out of debt. The extra practice could come in very handy.
There is arguably one thing worse than investing in shares while in debt, and that's actually taking out debt specifically in order to buy shares. This is just about the most un-Foolish thing you can do, as the value of your shares could easily drop. Your investing decisions would then by governed by your debts and the wishes of your creditors. That way disaster lies!
It is often said you should only invest money you can afford to lose. A more constructive way to consider it is: "if I lost this money, would it affect my day-to-day life or expenditure?". You also need some money for the proverbial 'rainy day'. A sensible rule of thumb is to set aside enough money for six months' expenditure in a high-interest savings account. But you may feel happier setting aside more money if, for example, you have a number of dependants, although you should probably be looking at some sort of income protection insurance for such situations.
If you need all your money for a specific purpose, like a deposit on a house or a tax bill, then buying shares is not for you either. It makes more sense to stick your money is in a high-interest savings account as well.
Historically, the long-term rate of return from the stock market has been significantly greater than that which is generated from cash saved in a banks. But it has also been more volatile. For periods of just one year, the stock market has historically only beaten cash 60% of the time. Not great odds. Not much better than a coin toss, in fact.
However, over longer periods the chances of shares beating cash are much higher. Five years is often used as a benchmark for the minimum period you should consider investing. Over this length of time, the stock market has historically beaten the returns from cash 80% of the time. Invest for as long as twenty years, and shares have won 98% of the time. Now that's more like it. So, the longer you are prepared to invest for, the better.