Every portfolio should be built around some strong pillars, stocks that provide stability and will be staples for many years to come. With such a framework in place, investors can afford to take on more risks with other companies, knowing they have safe stocks to rely on that can generate good returns for their portfolios.

The companies listed below -- Eli Lilly (LLY -1.90%), Home Depot (HD -1.92%), and Microsoft (MSFT 0.12%) -- offer not only stability but dividends, and together, they can help diversify your portfolio. Let's take a closer look at each individual stock to see why it's a solid investment to hold in your portfolio for many years.

1. Eli Lilly

Eli Lilly's diverse product mix means its products help a variety of different patients. Its drugs treat people with serious illnesses such as diabetes and cancer, and while it does have a top drug (Trulicity, which treats diabetes), it isn't overly reliant on it. In 2019, the drug's sales totaled $4.1 billion, less than one-fifth of Eli Lilly's total sales.

Green arrows pointing up.

Image source: Getty Images.

Even during the coronavirus pandemic, the drugmaker's business is proving resilient. Eli Lilly released second-quarter results on July 30 for the period ending June 30, and sales were down a modest 2% year over year. Many pharmaceutical companies are seeing much more significant declines as patients avoid visits to the doctor's office amid the pandemic, but Eli Lilly's strong Q2 numbers demonstrate just how essential its products are to patients -- and why investors can feel confident about it even during a pandemic. Year to date, Eli Lilly's sales are up 6%; it has benefited from patients stockpiling products earlier in the year.

In August, the company began phase 3 trials of its antibody drug LY-CoV555 to prevent the spread of the coronavirus, particularly in nursing homes where it's been difficult to contain. It's just another example of how versatile and adaptable Eli Lilly is, and why it's a great long-term investment.

Eli Lilly can also boost your portfolio with a lot of cash flow over the years, with its quarterly dividend of $0.74 yielding 2% per year -- right around the S&P 500 average.

2. Home Depot

During a time of technological change, with more businesses moving toward the cloud, it may seem odd to consider a retail stock like Home Depot a good forever stock to own. But many people still value in-store interactions, especially when they need advice on a home renovation or repair. That's why Home Depot is still likely to see demand for not only its products but also its services. Even if someone buys a cheaper product from Amazon, they may still go to their local Home Depot to get assistance on how to use it, which could lead to other purchases.

On Aug. 18, the Georgia-based company released its second-quarter results for the period ending Aug. 2, and sales of $38.1 million were up 23.4% from the previous year. That's very unusual growth for the retailer, which in its most recent fiscal year generated just 1.8% sales growth. 

A particularly strong segment for the company this past quarter was hardlines, which includes hardware, tools, and garden products. That part of Home Depot's business generated sales of $13.7 billion -- up 33.2% from $10.3 billion during the same period last year. Home Depot noted strong demand as people continued to focus on projects and repairs around the house, a trend that started toward the tail end of the first quarter when the coronavirus pandemic was still in its early stages in the U.S.

Home Depot's business is as strong as ever, and the home improvement company is one of the safer retail stocks out there today. It currently pays its shareholders a quarterly dividend of $1.50, which yields a little over 2% per year.

3. Microsoft

As more people work in the cloud and away from the office, demand for Microsoft's products will likely continue to climb. Businesses will be making more use of Microsoft's Azure cloud computing services, while workers will likely benefit from using its office products to help with productivity and the synchronization of work across multiple devices.

In August, the Washington-based company released a new feature that could add even more value for online workers, Transcribe in Word, which will allow subscribers to the Microsoft 365 suite of products to use Word to turn verbal conversations into written ones, including those that take place virtually through Zoom and other videoconferencing apps. 

When Microsoft released its most recent results in July for the year ending June 30, sales in the fourth quarter were up 13% even with the coronavirus pandemic slowing down growth. In the first quarter, its sales were up by 15%. A key reason Q4 was slower is that advertisers were spending less on ads, with revenue from search ads down 18%. A year earlier, that segment was growing at a rate of 9%.

Despite a relatively slow quarter, the tech giant still proved strong enough to grow amid the COVID-19 storm, a status many companies would envy. Microsoft continues to be a pillar in the day-to-day lives of businesses, workers, and students, and that's not likely to change anytime soon. And that's precisely why it should be a pillar in your portfolio as well. 

Although you probably won't be investing in Microsoft primarily for its dividend, it does currently pay its shareholders $0.51 quarterly, for a yield of just under 1% per year.

Which stock is the best of the three?

All three of these stocks are doing well this year and outperforming the S&P 500:

^SPX Chart

^SPX data by YCharts

While all three would be great to invest in right now, if you've only got room to add one stock, I'd suggest going with Eli Lilly. When looking at price-to-earnings multiples, it offers investors the best bang for the buck:

LLY PE Ratio Chart

LLY PE Ratio data by YCharts

With a more modest valuation, Eli Lilly is a better value buy, which could make it less prone to a correction should the markets nosedive again this year. And if the company's antibody drug proves to be effective in preventing the spread of COVID-19, that could send its shares soaring this year, giving investors all the more reason to buy the healthcare stock sooner rather than later.