Most of the high-tech chips that power data centers, artificial intelligence (AI) technologies, smartphones, and laptops originate from one place: Taiwan Semiconductor (TSM 1.26%), or TSMC. As the name suggests, the company is headquartered in Taiwan and has most of its operations there, although it has made significant investments in factories in the U.S.

But do the risks of investing in the company outweigh the potential rewards of owning one of the most vital companies for our digital society? Let's find out.

A China invasion poses a threat to more than just TSMC

Some of the most technologically advanced companies, like Apple and Nvidia, utilize TSMC's chips in their products. While the broader consumer electronic market is currently down and causing Taiwan Semiconductor some demand challenges, the future remains bright. Furthermore, with its new 3nm (nanometer) chip entering production, the gains provided by this technology will likely sway its customers to upgrade to the newest gaming or data center graphics processing unit (GPU) and iPhone.

However, the overarching risk of a Chinese invasion gives many investors pause when considering investing in Taiwan Semiconductor. No one knows what would happen, but in the best-case scenario, a critical supplier for digital products would be taken offline for some time.

That would cause the supply chain of vital components to be disrupted far worse than in 2020 and would likely sink almost every other stock in the market. So, if you're concerned about a Chinese invasion (a valid concern), it may be unwise to invest in the market whatsoever.

Because it is so vital to our digital society, I think investors should consider Taiwan Semiconductor for their portfolios. But you'll have to be patient, as Taiwan Semiconductor is a cyclical business.

Taiwan Semiconductor's stock is cheap compared to the market

Demand for TSMC's chips rises and falls alongside consumer sentiment, which is directly tied to the economic cycle. Some signs point toward a recession unless the Federal Reserve can engineer a soft landing. In any case, the consumer is far from their strongest right now, translating to weak sales for TSMC.

In the second quarter, revenue decreased by 10% year over year (in New Taiwanese dollars), and profits declined by 12%. TSMC also reports monthly revenue, and July looked like a bit of a relief from the trends experienced over the past few quarters. July revenue was up 14% compared to June but still down 5% from last July.

Still, this decline is only temporary as TSMC's chips are utilized in multiple areas, and the consumer's spending power will recover eventually. In fact, analysts project that TSMC's revenue will rise 23% next year.

As a result of its temporary business decline, using forward earnings in tandem with trailing earnings to judge how expensive the stock is from a historical perspective is a smart strategy.

TSM PE Ratio Chart

TSM PE Ratio data by YCharts. PE Ratio = price-to-earnings ratio.

While TSMC stock looks cheap from a trailing standpoint, that's because further earnings declines are expected throughout this year. However, even when that's factored in, you can purchase the stock for its average valuation over the past decade. Furthermore, the S&P 500 trades at 26 times trailing earnings, so it's much cheaper than the broader market.

As a result, investors should consider adding TSMC to their portfolio. TSMC's products will only become more essential in the coming years. Although there's the overarching risk of an attack by China, the rest of the market will falter in response.

The catch is that it will need to be a long-term holding, as the economic cycle will cause its results to fluctuate from year to year. However, if you come in with a mindset of holding the stock for at least five years, Taiwan Semiconductor will likely be a winning investment.