Generating passive income from your investments is an easy way to build and accumulate wealth over the years. The best income-producing stocks to hold in your portfolio are the ones that you can just tuck away for decades and not worry about. They'll simply continue paying (and hopefully increasing) dividends over the years, allowing your portfolio to grow over time.

The stocks listed below pay and regularly increase their dividends, are household names, and are likely to continue to be good investments decades from now. These are two stocks you can safely buy for the long haul.

1. Johnson & Johnson

Johnson & Johnson (JNJ 0.66%) is a top healthcare company known by consumers all around the world for its various products and drugs. The New Jersey-based company released its second-quarter results on July 16, and while it's not immune to the impact of COVID-19, it was still able to post a profit of $3.6 billion on sales of $18.3 billion. Revenue declined 10.8% year over year, but one segment that did well was pharmaceutical, where revenue grew by 2.1%.

The word Dividends spelled out over the top of a piggy bank

Image source: Getty Images.

Versatility is important during these difficult times, and with three strong business segments -- consumer health, pharmaceuticals, and medical devices -- Johnson & Johnson is a more stable long-term investment thanks to its diversification. In addition, the company's also working on a vaccine for COVID-19 that's shown progress in animals. Johnson & Johnson has begun human trials, and if the vaccine proves to be effective, the company could have as many as 900 million doses of it available by April 2021.

A successful vaccine would generate significant revenue for Johnson & Johnson and is just another example of the company's diverse, adaptable business model. The only foreseeable risk over the long term stems from the legal problems the company has endured in recent years -- in particular, lawsuits over its role in the opioid crisis and its talc baby powder products. However, as concerning as those issues are, they aren't likely to bankrupt the company or jeopardize its long-term future.

And that makes the Dividend King a solid income-generating stock to hang on to for decades, as its robust and diversified business looks to be in solid shape to weather any storm that may come its way. The healthcare stock's raised its payouts for 58 years in a row, and quarterly payments of $1.01 mean that investors today are earning an annual yield of 2.7% -- well above the S&P 500 average of 2%.

2. Walmart

Walmart (WMT -0.15%) is another company that investors can safely hang on to for decades. The big-box retailer is a safer buy than Johnson & Johnson in that it's not facing significant legal challenges, and it's also doing well during the pandemic. Walmart's first-quarter results May 19 revealed comparable-store sales up 10% year over year and e-commerce revenue that had soared by 74%. Management credited "unprecedented demand for products across multiple categories"for the boost.

For people who are sheltering at home and minimizing their trips to stores amid the pandemic, Walmart provides an easy way to do all their shopping at once, offering everything from candles to tires to frozen bagels. And Walmart's delivery services, which in some cities offer next-day delivery, can even help consumers who'd prefer not to visiting a store at all.

Walmart currently pays its shareholders a quarterly dividend of $0.54, which on an annual basis yields 1.7%. Like Johnson & Johnson, it also has an impressive streak of dividend increases going, having raised its payouts in February for the 47th year in a row. If it continues doing this for three more years, it'll also become a Dividend King. For now, it remains an Aristocrat.

Which stock is the better buy right now?

Here's a quick look at how the two stocks are doing thus far in 2020:

JNJ Chart

JNJ data by YCharts

Walmart's stock is soundly beating both Johnson & Johnson and the S&P 500 and could rise further when the company releases its quarterly results in August, in which it could show another strong performance amid the pandemic. If you're a conservative investor who is worried about Johnson & Johnson's legal headaches, then Walmart would be the better buy for you.

However, if dividend yield is more important to you -- along with avoiding exposure to what can be a volatile and highly competitive retail industry -- then Johnson & Johnson is the stock you'll want to put in your portfolio. Either way, both of these stocks should generate significant returns for decades, so holding both of them can also help diversify your portfolio.