Investing in the stock market is one great way to build wealth and achieve financial freedom. Investing can seem daunting, but it doesn't have to be. With patience, persistence, and a long-term outlook, anyone can succeed in the stock market. The key to building wealth and growing your portfolio is consistently adding and holding stocks for the long haul.

When you set aside a specific dollar amount per month, also known as dollar-cost averaging, you harness the power of compound returns. One simple and effective way to build wealth is by investing in the S&P 500 index, which contains the 500 largest companies in the U.S. You'd be surprised at how much $500 invested in the index every month over the last 20 years would be worth today.

A chalk board shows the growth of money over time.

Image source: Getty Images.

Two decades of investing would have made you this much

Dollar-cost averaging is a simple technique in which you invest a fixed amount of money in stocks or a fund over a long period of time. With this method of investing, you aren't trying to time the market to buy low and sell high. Instead, you consistently put money into your investment account over time. Dollar-cost averaging is a sound method of investing that removes some of the emotional stress from investing. 

One good way to illustrate the effectiveness of dollar-cost averaging over an extended time is with the S&P 500 index fund. One way you can invest in this index is through State Street Global Advisors' SPDR S&P 500 ETF (SPY -0.38%), the first exchange-traded fund (ETF) listed in the U.S. Their low expense ratio makes investing in an S&P 500 ETF financially attractive. The SPDR S&P 500 ETF has a gross expense ratio of just under 0.10%. Some other ETF options could have expense ratios up to 0.70% and can eat into long-term investment returns. 

If you invested $500 in the SPDR S&P 500 ETF every month over the last two decades, beginning in May 2003, you would have over $375,076 today. This amount includes your invested capital of $120,000 plus investment gains of $255,076. 

A simple way to become a millionaire

The secret to becoming a millionaire is simple: consistency. According to a study by Ramsey Solutions, 79% of millionaires didn't inherit their fortune, and one in three didn't even have a six-figure salary. Instead, eight out of 10 millionaires regularly invested in a 401(k) plan.  

Investing in the S&P 500 index is one way you can utilize this method, but it can also be an effective way to buy stock in companies you believe in over time. If you use it for individual stocks, you want to make sure you are doing it as part of a diversified portfolio across several stocks. That way, your portfolio isn't too concentrated in any single name.

What's great about dollar-cost averaging is that it is super simple and something you can set up to do automatically. Chances are you already do this if you have a 401(k) through your job, but you can also use this strategy in an individual retirement account (IRA) or a regular brokerage account. So if you're looking to build wealth to achieve financial freedom, consistency is a crucial component that will get you there.