Investing in the stock market works best when people adopt a truly long-term mindset. With a time horizon measured in decades, as opposed to days or months, investors can take advantage of the magic of compounding.

Historically, the S&P 500 has produced an average annual return of about 10%, including dividends. But there are some businesses that have absolutely crushed that gain.

In fact, $1,000 invested in one top retail stock at its initial public offering (IPO) in September 1981 would be worth nearly $32 million today. Let's learn more about this company's rise, as well as if the shares make for a smart purchase today.

Boring business; exciting returns

Investors might be surprised to know that the stock that has produced such a fantastic return is none other than Home Depot (HD 0.11%). The company sells home improvement products to both do-it-yourselfers and professional customers via its network of stores. It is the leader in its industry, well ahead of smaller rival Lowe's.

Key to the stock's impressive performance has been an expanding store footprint. Today, the chain has 2,335 stores, the vast majority of which are in the U.S. The company says 90% of the American population lives within 10 miles of a Home Depot.

Thirty years ago, there were only 264 stores. Seeing the potential to rapidly expand and replicate the business model, it's no wonder leadership was aggressively investing in growth. Consistent revenue and earnings gains were what helped propel the stock.

HD Revenue (TTM) Chart

HD Revenue (TTM) data by YCharts

At its current scale, the retailer is incredibly profitable. It generated $15 billion of net income and $21 billion of operating cash flow in fiscal 2023, which ended in January 2024, astronomically higher figures than during the IPO.

And the executive team has shown that it prioritizes returning capital to shareholders. In the past 24 months, Home Depot paid $16 billion in dividends and the stock currently yields about 2%. It has paid a dividend in 148 straight quarters, helping boost shareholder returns and propel that $1,000 to millions.

Is Home Depot stock a buy now?

In more recent times, owning shares of Home Depot hasn't been as exciting. But the stock has still rewarded investors. It has more than doubled in the last five years and has climbed nearly fivefold in the past decade (as of March 26). These gains exceed the S&P 500.

Nonetheless, it's prudent not to expect the stock's future to resemble the past. The company carries a massive market cap of $379 billion, and it generated $153 billion of sales in fiscal 2023. Growth has tapered off and will continue to do so.

The business is dealing with a slowdown following a surge in demand for renovation projects during the early, stay-at-home days of the pandemic. Revenue declined 3% last fiscal year, with management expecting a 1% rise in the current fiscal year. Investors might hesitate to pay a price-to-earnings ratio of 25 for a business that isn't growing right now.

But I still think now is a smart buying opportunity for long-term investors. Home Depot dominates its industry, possesses a strong brand, and has the resources to develop its supply chain and omnichannel capabilities.

The result is that the business will continue to be second to none when it comes to serving its customers. This should help it continue to take market share in the $950 billion home improvement industry, and once economic headwinds subside, Home Depot should get back to registering its typical growth. Investors are likely to be rewarded.