Home improvement giant Home Depot (HD -0.31%) spooked investors last week after it reported underwhelming earnings and adjusted its guidance downward for the year. A slowdown in consumer spending is finally starting to hit the retailer hard.

But despite the near-term trouble, investors should stay the course and keep Home Depot's stock in their portfolios, or even consider adding it on the current weakness. Here's why it can be a great buy right now.

Sales now expected to decline this fiscal year

On May 16, Home Depot released its first-quarter numbers while also updating guidance for fiscal 2023. The results were concerning to investors as sales of $37.3 billion for the period ending April 30 were down 4.2% year over year. Comparable sales were also down 4.5%.

It's not a great picture for the state of retail, and the company now projects its sales to drop between 2% and 5% for the current fiscal year. Previously, Home Depot was projecting its sales growth to be flat.

But as bad as the decline in revenue may sound, it's not a trend long-term investors should be overly concerned about in the big picture. Home repair and renovations are expenses that homeowners have to face, sooner or later. While it's not a necessity and perhaps is an expense that can be pushed back, particularly in a year when consumers are struggling with inflation, it's not entirely avoidable.

Why sales should inevitably recover

According to a survey from insurance company Hippo, 77% of homeowners have an unexpected expense to worry about as early as the first year of homeownership. And the company says that last year, homeowners incurred repair and maintenance costs totaling on average $6,000. It's such an ongoing cost of home ownership that a general rule of thumb is to allocate at least 1% of a home's value aside each year to help cover these types of expenses.

The danger is that if homeowners postpone necessary repairs and maintenance, it can lead to more expensive, costly repairs in the future. That's why, although Home Depot may be seeing a drop in demand this year, this is not a problem likely to persist for the long haul.

An encouraging trend for investors is that not only has revenue generally increased over the years for Home Depot, but profits have grown at an even faster rate.

HD Revenue (Annual) Chart

HD Revenue (Annual) data by YCharts

The stock looks cheap right now

Another great reason to buy Home Depot's stock is that investors are getting a lot of value for their money today. Historically, the home repair stock has traded at 22 times trailing profits. It's currently well below that average.

HD PE Ratio Chart

HD PE Ratio data by YCharts

Home Depot's stock is a no-brainer buy

As long as you're willing to buy and hold, Home Depot can make for an excellent stock to tuck away in your portfolio for years. Even with a decline in revenue, the company's diluted per-share earnings last quarter totaled $3.82 and were down 6.6%.

That's more than enough to cover its quarterly dividend payment of $2.09, putting its payout ratio at approximately 55% of earnings. That's a healthy ratio that suggests there may be room for increases to the payout in the future, and that at the very least, Home Depot's streak of paying dividends for 145 consecutive quarters looks safe.

Whether you're a dividend investor or looking for a good, stable business to invest in, Home Depot is an investment that makes a lot of sense right now. It's an attractive retail stock to buy on weakness as it's currently within 10% of its 52-week low.