Investors are starting to feel optimistic again. The S&P 500 index just had its best week of the year after a market swoon in October. When investors -- and consumers -- are feeling good, many stocks can do well. But one that will also pay you back handsomely for your investment is Home Depot (HD 0.94%).

Home Depot shares are still down for the year, compared to a gain of about 13.5% for the S&P 500. And while the benchmark index pays a dividend of about 1.5%, Home Depot shares yield about 2.8%. What might matter even more for investors is that company's history of raising its payout to shareholders.

Magnificent dividend legacy

It's not just the juicy dividend yield compared to the index that should have investors salivating. Home Depot has grown its dividend at a very impressive rate over the last decade. As it has grown sales from both its residential and professional customers, Home Depot has more than quintupled what it has given back to shareholders in the form of dividends over the 10-year period.

HD Dividend Chart

HD Dividend data by YCharts

That's also not the only way the company is giving back to shareholders. In that same period, Home Depot has repurchased about 30% of its share count. That gives shareholders a bigger piece of the company's earnings. Home Depot's board of directors authorized another $15 billion share repurchase program in August. So investors will continue to benefit from that return of capital as well.

The business still has legs

The stock itself has dropped more than 6% year to date as the current cycle of rising interest rates has brought mortgage rates to their highest level in more than 20 years. The company expects full-year sales to decline by as much as 5% compared to 2022. Yet there are signs that both homebuilders and homeowners continue to spend. That could mean a rebound in sales growth could be coming in 2024.

Recent quarterly updates from homebuilder D.R. Horton and composite decking manufacturer Trex indicate a recovery in the sector is already underway. Trex said its third-quarter sales soared 61% versus the same period last year, and net income rocketed 350% higher. D.R. Horton chairman Donald R. Horton commented in his company's fiscal 2023 fourth-quarter earnings release this week:

Despite continued higher mortgage rates and inflationary pressures, our net sales orders increased 39% from the prior year quarter, as the supply of both new and existing homes at affordable price points remains limited and demographics supporting housing demand remain favorable.

Those are both good signs for Home Depot, and it gives investors another reason to add Home Depot shares now.

Investing for the future

As mentioned, the stock has significantly trailed the overall market this year. It's reasonable to think that returns from the stock alone can outpace the market as investors see strength returning in the sector. A swing to a declining interest rate environment in the next couple of years could well bring Home Depot stock back in favor for investors.

But for those investing for the future, that's not even really the key attraction. Based on its history, Home Depot's dividend is likely to continue to grow as long as the business remains strong throughout the various economic cycles.

That could provide meaningful income in retirement. With the S&P 500 jumping, and Home Depot shares trailing that index, now is the time to buy the stock and get ready to welcome a growing income stream down the road.