The U.S. stock market might be the best vehicle for wealth creation in the history of the world.

It's made millions of investors rich, and it will almost certainly continue to do so for generations to come. The total value of the U.S. stock market is now roughly $46 trillion, and anyone can take advantage of it. All you need to do is open a brokerage account and invest what you can.

Investing works best with a long time horizon, as the power of compounding means that your investment will accumulate wealth faster as it grows.

The chart below, which shows the value of $10,000 invested in the S&P 500 index fund (INDEX: ^SPX) 50 years ago, helps illustrate the magic of compounding.^SPX Chart

^SPX data by YCharts

As you can see, that single investment grew to more than $500,000, excluding dividends. But what's also notable is that much of the wealth created by that investment came in the last few years. In fact, about half of it came in the last seven years, while it took 43 years to make the same amount of money before that.

A person holding up a wad of bills.

Image source: Getty Images.

One way to become a millionaire

The S&P 500 is the best available proxy for the U.S. stock market. The index contains 500 large-cap U.S stocks, and the S&P Global, which runs the index, refreshes it frequently, ensuring that rising stars are added to it and laggards are removed.

As a result, the broad-market index has an excellent historical track record of generating wealth. Over its history, the S&P 500 has generated an average annual return of 9%, including re-invested dividends.

At that rate, even a middle-class income is enough to become a millionaire over time. $500 a month, for example, is less than 10% of the median U.S. household's monthly income. For example, if you are able to commit to investing $500 a month in an S&P 500 index fund like the Vanguard 500 Fund (VOO -0.03%), you'll eventually have $1 million, and that includes paying the 0.03% expense ratio in the ETF, meaning you'll pay 3 cents each year for every $100 you have invested in the index fund.

If we assume an average growth rate of 9%, it would take 31 years for that investment to reach $1 million, and that assumes that you are starting from zero. It also means that you only invested $186,000 over the course of those 31 years, getting more than five times the return on your investment.

Like the chart above that traces a $10,000 investment in the S&P 500, you'll find that the returns are weighted toward the end as well. According to the math, it would take you roughly 24 years to reach $500,000, but you would earn the remaining $500,000 in the next seven years. By the final year of that plan, your investment would be increasing by nearly $100,000 a year, and it would continue to accelerate into the future.

Want to get there faster?

If you want to become a millionaire but don't want to wait 31 years, you have a couple of options. The easiest one is to invest more money. If you can commit to investing $1,000 a month, you could reach your goal within 24 years, for example, and $2,000 a month would allow you to get there in less than 18 years.

The other variable, which you have less control over, is your rate of return. If the S&P 500 outperforms its historical average and generates, say, a 12% annual return, you would reach $1 million in 26 years by investing $500 a month. You can try to find another ETF that will beat the S&P 500, but doing so is difficult, and even professional money managers struggle to beat the broad-market index.

Buying an ETF like the Vanguard 500 Fund and committing to investing in it every month is one of the easiest ways to build wealth that you'll find. While you won't become a millionaire overnight, you almost certainly will with enough time.