Investing in stock market shares is not without its risks. They can rise significantly in value over many years, go into periods of decline, or fall suddenly in value, with no guarantees you will get back the full amount you invest.
The key point to remember is that saving into a pension is a long term investment, and the longer you remain invested in the stock market the better you tend to do.