One of the dangers with investing in stocks is giving too much weight to near-term factors and conditions that may not last over the long term. Many investors are down on struggling stocks because of their recent performances or projected guidance. But if you want to find a good stock to invest in, you should consider what's ahead for the business and where it might be a few years from now, rather than how it might do over just the next few months.

One stock that investors haven't been excited about this year is Best Buy (BBY -0.25%). The retail stock has fallen 8% year to date, and over the past three years, it's down over 30%. But despite those poor returns, here's why the stock could be a much better buy moving forward.

The PC market will inevitably rebound

Demand for personal computers (PCs) has been underwhelming, with research company Gartner reporting that worldwide PC shipments during the second quarter were down 16.6% versus the same period last year. It marks the seventh consecutive quarter where shipments were down year over year. But the company does note that "shipment volumes may have reached their lowest point."

Best Buy's business isn't all about PCs, but they're a big part of it. And as people buy or upgrade PCs, they may also be looking for new peripherals, speakers, and other products. PCs aren't made to last forever, and upgrades are inevitable. There was pent-up demand for travel, and there could very well be pent-up demand for electronics and computer upgrades in the future.

As of now, companies and consumers are scaling back on expenditures due to inflation and worsening economic conditions. But over time, this isn't a trend that investors should count on continuing. CEO Corie Barry commented, "Next year the consumer electronics industry should see stabilization and possibly growth driven by the natural upgrade and replacement cycles and the normalization of tech innovation."

Best Buy's business is still doing relatively well

Best Buy recently downgraded its outlook for sales this year, but only modestly. Full-year revenue will be within a range of $43.8 billion to $44.5 billion versus a previous forecast of $43.8 billion to $45.2 billion.

Through the six-month period ending July 29, the company's revenue has totaled $19.1 billion, which is down 9% year over year. That's not a huge slide given the soft PC market. And while operating income of $659 million has fallen by 21%, the company's operating margin of 3.5% is only down slightly from 4% in the year-ago period.

The dividend is looking great

The retailer's earnings per share last quarter was $1.25, which was still easily enough to cover Best Buy's quarterly dividend payment of $0.92. If it maintained that level of profitability, its payout ratio would be around 74%. That's not bad for the company in light of the current market conditions.

And with the falling share price, Best Buy's dividend yield is 4.9%, which is more than 3 times the S&P 500 average of 1.5%. For investors who crave a high-yielding dividend stock, Best Buy could be a great buy right now.

Best Buy's valuation is attractive

Best Buy's recent earnings have been underwhelming and they should improve in the future. But even as the bottom line has deteriorated, the stock's valuation looks good given its weakness.

BBY PE Ratio Chart

BBY PE Ratio data by YCharts

At around 13 times trailing profits, investors are getting some good value here; the S&P 500 averages an earnings multiple of 20. And over time, as the consumer electronics market improves, Best Buy's earnings should strengthen, potentially making it look like an even better investment in the future.

Best Buy's stock is a great option for long-term investors

If you're looking for a good stock to buy that also offers a high dividend, it's hard not to like Best Buy right now. It's a bit of a contrarian pick given its falling revenue, but demand for PCs and electronics will rebound, and when it does, there could be a lot more bullishness behind this retail stock. Buying it before that happens could result in some great returns for investors.