Stock prices have been erratic recently, to say the least, and the market's volatility is an important reminder of why long-term investing is often a safer strategy than focusing on the moment. If you're looking to invest for years and decades rather than weeks and days, you can buy and forget about your investments without worrying about short-term fluctuations. The key is picking stocks that are financially strong and whose futures look to be relatively safe and predictable. The two stocks below can be solid long-term buys for investors who just want to buy, forget, and hold for decades.

1. Cardinal Health

Cardinal Health (NYSE:CAH) is a top healthcare company with a presence in 46 countries and 50,000 employees around the globe. The company is involved in the distribution of pharmaceuticals and also manufactures various surgical and medical products. Over the long term, investing in Cardinal may come with some risk, especially with opioid legislation posing a possible financial burden for companies. But many pharmaceutical stocks that make or distribute opioids will face those risks. Cardinal's strong financials position it well to handle such adversity, making it a good long-term buy despite those potential expenses.

Only once during the past six years have the company's profits fallen below $1.1 billion. Although its profit margin is very slim, sometimes below 1%, with more than $145 billion in revenue in fiscal 2019, Cardinal can still produce strong profits given its high sales volume. And it's still growing, with sales expanding by 6.4% in its most recent fiscal year. It's also consistently generated positive free cash flow in each of the past 10 years. In five of the past six years, free cash flow has also been very strong, at more than $2 billion.

An open bottle of prescription medication, with white pills spilling out.

Image source: Getty Images.

Another good reason to buy the stock is that it's a Dividend Aristocrat that's increased its payments to shareholders for more than 30 years in a row. Its current quarterly payout of $0.48 is up more than 40% from the $0.34 it was paying at the beginning of 2015. Currently, its dividend yields more than 3.6% annually, and it's likely to keep growing over the years.

2. Visa

Visa Inc. (NYSE:V) is one of the best stocks investors can hold for the long term. With consumer debt a significant problem in the U.S., the need for credit looks to remain strong for the foreseeable future. In its fiscal year 2019, Visa's revenue of $23 billion grew at a rate of 11% from the prior year, when its top line was $20.6 billion. What's perhaps most remarkable about the stock is just how profitable its business is -- its operating margin has remained above 60% for seven straight years. The company's net income has been a bit more volatile, but Visa's profit margin is typically over 40% as well, falling below that threshold just twice in the past seven years.

There's strong demand for Visa's credit cards, and with its impressive financials, the stock is a solid long-term investment. It's hard to go wrong with any credit card provider, but Visa's an industry leader and has the strong name recognition that gives it an edge over its competition.

The company also provides investors with a quarterly dividend that currently pays $0.30. That accounts for a modest dividend yield of about 0.65% annually, which is well shy of the S&P 500 average of 2%. It's not a big payout, but Visa's been increasing its dividend payments over the years. Five years ago, the stock was paying just $0.12 every quarter. And while it doesn't have the long track record of Cardinal Health, if Visa continues producing strong financial results, it could be well on its way to becoming an Aristocrat as well.

Both stocks can offer good diversification for investors

For investors who want some long-term security for their portfolio, diversification is important. Holding these two stocks is a good way to accomplish just that. They pay dividends, generate strong sales, and are safe bets to post profits as well. Here's how their share prices have performed over the past 12 months:

V Chart

V data by YCharts

While Cardinal Health has lagged behind the S&P 500, with the stock now trading at a forward price-to-earnings (P/E) ratio of just 10, it could be an attractive buy. Visa, by comparison, trades at a forward P/E of 30 -- noticeably higher, but not unreasonable, given its strong sales growth. Having both of these dividend stocks in your portfolio can help provide some balance and good returns over the long term.