Longevity and reliability are important features for any stock that you buy for your retirement account. You probably don't want to stake your nest egg on a company that crumbles against the competition, even if it has promising growth prospects. There's no way to completely eliminate risk when you buy stocks, and we can't possibly know what the future holds several decades from now. BlackBerry was comfortably atop the global smartphone market less than a decade ago, and now it's a completely different company.

If you want a stock you can keep forever, you'll need to find companies with real staying power and clear competitive advantages. Here are three different ideas from the top of the pile.

Person writing "Focus on the Long Term" in a notebook.

Image source: Getty Images.

1. 3M

3M (MMM 0.79%) is an industrial conglomerate that produces a broad portfolio of around 60,000 products. Its major categories are safety, transportation, electronics, healthcare, and consumer goods.

If you're looking for an innovative growth stock, 3M isn't for you. This company is a mature behemoth that tends to inch along with the global economy. It doesn't intend to be a high-growth entity; 3M instead focuses on delivering reliable cash flows and passes those along to shareholders as dividends.

3M stakes its claim as a forever stock based on those stable cash flows and the sizable economic moat it's built. The company's massive scale allows it to minimize input costs for the goods it produces, making it difficult for smaller competitors to compete on price. 3M can also sustain a massive budget for acquisitions and research and development to ensure that its product offering remains best in class. The company has numerous strong brands as well, which are so diverse that competition in any single product category wouldn't be devastating.

That moat is evidenced by 3M's 19% return on invested capital (ROIC). This high number indicates that the company is efficiently using its financial resources to generate profits, due to pricing power and efficiency from its competitive advantages.

3M looks like a safe bet for the long term, even if it's not doing anything exciting. The stock currently pays a healthy 3.2% dividend yield at a sustainable 59% payout ratio, so it's an income investment.

MMM Return on Invested Capital (Annual) Chart

Data by YCharts

2. Microsoft

Microsoft (MSFT -0.94%) is a more dynamic option than 3M, but you'll have to accept more uncertainty to own it. It's a more suitable stock if growth is one of your primary investment goals.

Microsoft makes this list due to its impressive competitive position in a handful of growth markets. Windows absolutely dominates the global laptop and desktop operating system market. Over 30% of all computers run Windows, despite Microsoft having zero presence in mobile devices. Microsoft is also a major player in email hosting and productivity software with its Outlook and Office product suites. The company has a major foothold in gaming as well, with the Xbox console and associated games and marketplace.

Most importantly for Microsoft's long-term narrative is Azure, its cloud computing service. Cloud services are essential for a modern economy in which businesses from every industry are tech-enabled. Microsoft trails only Amazon Web Services in cloud market share, setting it up as a major player for years to come.

That level of diverse tech leadership has only been achieved by a few other stocks. Anything could happen in a rapidly evolving tech landscape, but Microsoft provides an intriguing mix of stability and growth.

3. Johnson & Johnson

Johnson & Johnson (JNJ -0.28%) is a healthcare giant that makes this list due to its diversified operations, prominent market position, and vast R&D budget. There are numerous important factors that should keep this company moving forward over the long term.

Johnson & Johnson is among the global leaders in three completely different categories:

  • Consumer health (skincare and beauty products, OTC medication, Band-Aids, soaps, feminine hygiene, oral health)
  • Medical devices (orthopaedics, surgical tools, interventional systems, vision care)
  • Pharmaceuticals (a broad portfolio with several product categories, numerous blockbusters, and over 50 new candidate applications in late-stage development)

These segments contributed 16%, 30%, and 54% of total sales in the first half of 2021, respectively. Just under half of Johnson & Johnson's total sales are international, so it's not over-exposed to any single country. The company simply has too many market-leading products for it to fade quickly into obscurity, and it's also relatively protected from recessions because these products fulfill basic needs. It also pours substantial resources into developing new products -- more than $13 billion in the past 12 months alone -- far surpassing its major competitors, which should allow it to maintain its competitive position for a long time.

All of this has translated to a stock with top-notch fundamentals. The company boasts excellent financial health with high liquidity and very manageable leverage, around $20 billion in annual free cash flow, and an impressive 18% ROIC. Johnson & Johnson is also a Dividend Aristocrat with nearly 60 consecutive years of growing dividends, and it currently pays a 2.5% yield. It might not be all roses all the time for Johnson & Johnson, but it's a great bet to keep churning out cash for the long haul.