The stock market isn't a gamble. It's a strategy.
Growth is the tendency for an investment to grow over the long term. Volatility is the tendency for an investment's value to zigzag upward and downward in the shorter term.
Growth and volatility are a matched set.
- A bank savings account has very poor growth (e.g. 1%) but zero volatility - the 1% is a sure thing.
- The stock market jinks and janks up and down 30-40% in a fun year - but in the very long term (20+ years), its growth is very certain and very good.
The people who make a science of studying long-term growth are the people who manage university endowments -- billions of dollars of capital whose job is to pay a dividend to the university of 4-7% per year, which then funds the university's operations. When you hear about a named professorship, that's because somebody donated something on the order of $5 million so the college could draw off $250,000/year to fund the professor, assistants, real estate he requires, etc.
Endowment money is not gambled; it is closely watched with high degrees of professional accountability and chain-of-approval. Every move must be able to be proven to be correct. Endowments are typically about 70% invested in the stock market.
As good as stocks are over 20 years, they are absolutely fantastic over 50 years. And arriving at middle age realizing I failed to save for retirement in my early years (an age-1 IRA was foolishly cashed in at age 25), I very, very much wish I had enjoyed 20 more years of the multiplying factor of the stock market. Had I not liquidated the $2000 IRA, 20 years later it would've been worth $19,487 - I was going to armwave $20,000, but decided to actually look it up.
So if you have the willpower to stick to the plan, I cannot emphasize enough the value of socking that money into a retirement account today, particularly whatever your government offers in a tax-deferred (like the US IRA) or tax-exempt account (like the US Roth IRA). Honestly, whatever plans you have for the money 5 years from now, will feel stupid when you are 75 years old and it's the difference between surviving and enjoying life.
Other than that, given the 5-year planning window, I would say that the stock market is a serious risk, regardless of the state of the market.
They say you're not supposed to think about the state of the market ("timing the market"), but my sense of the state of the market is high-flying free-market giddiness relating to the US president and his policies which are very favorable for short term growth (at risk of creating a bubble/boom-bust cycle), and right now it feels like we're right in the boom. Housing prices are spiraling upward, and there are 2-3 "For Sale" signs on every block of houses. It really feels like 2006. So no, not a good time to buy stocks for a sell in 5 years.