Charlie Munger, Warren Buffett's longtime partner, passed away at age 99 last month. Perhaps Munger's biggest legacy? Spurring Buffett to switch from investing in very cheap stocks to investing in high-quality businesses at reasonable prices.

That's because whatever a stock may do in the near term or whatever its current valuation multiple, Munger taught us that over a long time period, stocks tend to return close to the return on capital of the underlying business.

In a 1995 speech, Munger said:

Over the long term, it's hard for a stock to earn a much better return than the business which underlies it earns. If the business earns 6% on capital over 40 years and you hold it for that 40 years, you're not going to make much different than a 6% return -- even if you originally buy it at a huge discount. Conversely, if a business earns 18% on capital over 20 or 30 years, even if you pay an expensive looking price, you'll end up with a fine result.

That's why for investors truly looking at the long term, a focus on quality, competitive advantage, and a high return on invested capital (ROIC) is crucial to success. And it's also why the following three tech stocks should be targets for your new investment dollars today, even after impressive year-to-date runs.

Microsoft

Microsoft (MSFT 1.82%) may be the second largest stock in the world, but that doesn't mean Microsoft can't continue rewarding shareholders. After all, Microsoft was the largest company in the world in the year 2000. Despite massive gains since then, it's only the second-largest today. So... lots of room to grow.

Over the past 25 years, Microsoft has always had a very high return on capital by virtue of its dominant position in Windows operating systems, the Office enterprise software suite, and the Dynamics enterprise resource planning system. But over the past decade, the company has had a renaissance under CEO Satya Nadella, who took over as CEO almost exactly 10 years ago.

Under Nadella, Microsoft has muscled its way into a strong No. 2 position in the all-important cloud computing infrastructure market, with some analysts saying it could become the No. 1 cloud infrastructure-as-a-service vendor by the end of this decade.

That would probably come about through Microsoft's savvy investment in OpenAI, the company behind ChatGPT. That foresight has catapulted Microsoft to the lead in the artificial-intelligence race. And despite some recent turmoil at OpenAI, it's still regarded as the AI leader. Given that we're still in the early innings of the AI races, there should be a lot of growth ahead for both OpenAI and Microsoft together.

While AI and cloud get the lion's share of attention, investors also shouldn't overlook Microsoft's other acquisitions during Nadella's tenure, such as the 2016 purchase of LinkedIn, or this year's acquisition of Activision Blizzard. The fact that Microsoft was still able to acquire such a large company despite its already massive size speaks volumes about Microsoft's still-hungry attitude despite its historical success.

The best part? Every one of Microsoft's businesses is insanely profitable. In fact, Microsoft's overall operating margin stands at a ridiculously high 47.6% over the past 12 months, with a return on equity of 39.1%. And keep in mind, this is during a somewhat soft year for enterprise software spending.

No wonder Microsoft has a higher credit rating than even the U.S. government. While that doesn't mean Microsoft stock is totally risk-free, it's probably the closest thing to it in the stock market today.

Sign saying focus on the long-term.

Image source: Getty Images.

Micron

Unlike Microsoft, Micron Technology (MU 2.92%) is not reliably profitable. In fact, over the past 12 months, the company has generated an operating loss of $6.2 billion. That's because the memory industry is in a severe bust following the pandemic -- its worst since the Great Financial Crisis.

So why is Micron a tech stock to buy and hold for the long term? It comes down to scarcity. Since the memory industry is so challenging, with severe boom-and-bust cycles, the global memory industry has consolidated to just three large DRAM companies and six large NAND flash companies.

Micron plays in both types of memory, but it has nearly three-quarters of its revenue coming from DRAM. And while DRAM is the most consolidated of the two types of memory, it's also the one that's likely to benefit the most from artificial intelligence.

That's because AI training systems need massive amounts of volatile data to process in order to train algorithms. That requires a very premium and high-intensity type of DRAM called high-bandwidth memory. Micron will be ramping up its cutting-edge HM3E generation in early 2024, which management boasts will have 10% better performance and 30% lower power consumption compared with the best solutions on the market today.

Meanwhile, the industry appears to be turning up. All three major DRAM players have cut back on their spending and reallocated equipment toward leading technology nodes. That supply cut, along with AI-driven demand, is allowing prices to rise again.

Micron reported fiscal first quarter earnings last week, with revenue up 18% quarter-over-quarter, ahead of expectations. While that was impressive, Micron guided for another 12% quarter-over-quarter growth in the current quarter, with profitability inflecting upward.

MU Return on Invested Capital Chart

MU Return on Invested Capital data by YCharts

So while Micron is inking losses today, it appears the industrywide supply cutbacks and AI-fueled demand are sowing the seed of the next "boom." Keep in mind, during the 2018 memory boom, Micron's ROIC reached as high as 40%.

Given we are at the early stages of the next upturn and the industry is unlikely to see a demand blowup like the post-pandemic downturn, competitively advantaged Micron is another stock to which one can allocate long-term dollars today.

ASML Holdings

Of the three mentioned stocks here, ASML Holdings (ASML 2.04%) has the highest efficiency, with a stunning 76.3% return on equity over the past 12 months.

One can think of ASML as a key "pick and shovel" player in the AI gold rush. In fact, all leading-edge semiconductors manufactured on nodes 7nm and lower need ASML's extreme ultraviolet lithography (EUV) machines. What's so attractive about ASML is that it has a monopoly on EUV, as the technology is insanely difficult to pull off. In fact, EUV development took over 20 years and billions of dollars in research and development, with partner contributions, to bring it to market in the first place.

EUV is required for all of the latest AI chips, including Nvidia's (NVDA 6.18%) market-leading H100. Meanwhile, the upcoming H200 and B100 slated for 2024 will also need plenty of EUV machines. And given the intense competition coming from other chipmakers challenging Nvidia's crown, it's fair to say ASML's EUV machines will remain in high demand, no matter which chipmaker comes out on top.

But its not just logic chips that require EUV. In fact, the memory industry, including the aforementioned Micron, is just beginning to use EUV in the production of DRAM chips. Micron predicts it will ramp up its first volume production of 1-gamma DRAM chips using EUV in 2025 -- Micron's first node to use EUV technology.

With a monopoly on crucial technology and a long runway for AI-fueled growth, ASML is a company that seems set to thrive over the medium to long term.

That's why even at a 35 times earnings ratio, it's a stock investors can feel comfortable buying and holding for the long term today.