International Business Machines (NYSE:IBM) has had a rough couple of years. The company's hardware business has been on the decline, and this has driven revenue to fall in both 2012 and 2013. IBM was slow to adapt to the cloud. Its loss of a CIA contract to build a private cloud to (NASDAQ:AMZN) last year was an embarrassing failure for the storied company. But even with these recent struggles, IBM still has a very deep economic moat, and the cloud isn't going to change that.

The power of the mainframe computer

Source: IBM

In 2012, only about 4% of IBM's revenue came from selling mainframe computers, the hulking systems that look more like a refrigerator than a modern piece of technology. However, including all of the hardware, software, and services related to the mainframe, these systems were responsible for 25% of IBM's revenue and nearly half of IBM's profits.

During IBM's most recent quarter, revenue from System Z mainframe systems declined by 40% year over year. While this may seem ominous, this decline is actually right in line with what the mainframe business has done historically. Each time a new mainframe system is released, sales rapidly rise as organizations upgrade their systems. This rise is then followed by a steep decline, and the cycle begins anew.

Why are companies still buying mainframes when the cloud seems to be the solution to everything these days? Well, IBM's mainframes can process an enormous number of transactions in an extremely reliable and secure way. The mean time between failure, or MTBF, is more than 20 years, and redundancies are built in to avoid any single point of failure. The architecture is such that there is no threat of viruses and little chance of hacking, something that cannot be said for servers or cloud systems.

Avoiding downtime
This level of reliability and security makes mainframes ideal for running mission-critical business processes where any downtime would be catastrophic. In 2012, 96 of the world's top 100 banks used IBM's System Z mainframes to process transactions, and the rise of mobile transactions only makes the argument for mainframes stronger.

Mainframes are not for everyone, though, and the market for cloud services is almost certainly going to grow far faster than the market for mainframes. But organizations that rely on the mainframe for mission-critical processes are extremely unlikely to move to the cloud.

Public clouds like Amazon's, while generally reliable, have had some major failures over the past few years. In October 2012, a memory leak related to a replaced server snowballed into a widespread outage, interrupting services like Reddit, Foursquare, and GitHub. In August 2013, a hardware failure related to a single networking device led to data loss and issues with services like Instagram, Vine, and AirBnB.

Moving to a private cloud
A private cloud would solve the issue of security, as organizations with sensitive information should be reluctant to trust that data to a public cloud, but it would still be subject to the same types of problems. Cloud systems have redundancies built in so they can avoid issues like this, but with so many things that could go wrong, something inevitability will. The CIA contract that IBM lost to Amazon was for a private cloud very likely based on the x86 architecture, much like Amazon's public cloud, and not mainframes, and in that area IBM doesn't have much of an advantage. IBM has since sold its x86 server operations to Lenovo.

One company that absolutely needs the level of reliability that only mainframes can offer is Visa. Visa operates one of the largest electronic payment networks in the world, with trillions of dollars in payment volume going through its systems each year. Over the past 20 years, Visa's system has had 100% availability, with the company pointing out that even during the busy holiday season, there has never been any downtime whatsoever. IBM mainframes make this possible, and Visa offers a great example of why IBM's mainframes are here to stay.

The bottom line
While IBM adapts to a changing technological landscape, sells off some businesses and invests in new ones, the mainframe computer remains at the heart of the company. The mainframe is the source of IBM's most important and durable competitive advantage, and it will be the source of a significant portion of the company's profits for years to come.

This article represents the opinion of the writer, who may disagree with the “official” recommendation position of a Motley Fool premium advisory service. We’re motley! Questioning an investing thesis -- even one of our own -- helps us all think critically about investing and make decisions that help us become smarter, happier, and richer.