I'm sure most investors know that the stock market is perhaps the best tool there is to build lasting wealth. For example, the S&P 500 has produced an annualized return of 10% historically. Given enough time, even relatively small sums of capital can turn into huge amounts.

But some individual businesses have fared much better. One top retail stock has produced a total return of 2,714,000% since its initial public offering in 1981. If you invested just $1,000 in this company back then, you'd have a jaw-dropping $27 million today.

The business I just described is none other than Home Depot (HD 1.03%). Let's learn more about its rise over the years before considering its investment merits today.

Doing the same thing

What's remarkable about Home Depot's historical performance is that it has come from a business that's in a boring industry. Through its network of massive warehouse stores, the company sells home improvement tools, parts, and supplies to both DIY and professional customers, something it was doing decades ago.

Home Depot's founders made the right strategic decision early on to focus their resources on expanding the store footprint, basically replicating what worked to more locations across the country.

About 30 years ago in fiscal 1993, Home Depot operated just 264 stores and generated $9.2 billion in annual sales. Today, there are 2,337 locations, and the business raked in $153 billion in revenue in fiscal 2023. This has become one of the world's biggest retailers, sporting a market cap of $324 billion.

As the business scaled up, it was easier to generate greater profits. That's partly due to Home Depot also being able to boost same-store sales, thanks more recently to bolstering omnichannel capabilities to better serve customers in ways most convenient for them.

This is a cash-flow machine these days. And it allows the management team to return excess capital to shareholders. Just in the latest fiscal quarter, Home Depot paid out $2.2 billion in dividends and repurchased $649 million worth of stock. These capital allocation moves work to the benefit of investors.

Is Home Depot a good stock to buy?

Given its size, I believe future returns for Home Depot won't come close to resembling past returns. In other words, a $1,000 investment won't turn into $27 million in the next 43 years. But that's not a deal breaker. In fact, this stock could still outperform the S&P 500 over the next five years.

Home Depot benefits from some powerful industry tailwinds. One of them is the aging housing stock in the U.S., a figure that has steadily increased over the years. Older homes require more maintenance and upkeep, a trend that can work in the company's favor.

The U.S. also doesn't have enough new homes to satisfy demand from consumers. The housing shortage encourages people to remain in their current dwellings, instead investing in renovation projects.

This long-term backdrop puts Home Depot's current situation in context. After the business reported a same-store sales decline of 3.2% in fiscal 2023, executives believe it will post a 1% drop in the current fiscal year. These are certainly difficult times for the company, as it struggles to register growth when inflationary pressures continue to negatively impact consumers and their willingness to spend on big-ticket items.

But for investors who can look out over the next several years, as opposed to the next few quarters, there's a solid buying opportunity here. Home Depot shares trade at a price-to-earnings ratio of 21.9, which is below the trailing-10-year average. Now looks like a good time to add this winner to your portfolio.