Well the first thing to remember is that IBM didn't own the IP to anything that actually went into the IBM PC besides the BIOS ROM software. There was nothing stopping third party suppliers (like MS and Intel) from supplying an alternative maker. Compaq hired a group of engineers to reverse engineer the IBM BIOS from scratch in a manner that was legally watertight. Compaq and other companies then started making fully compatible clones.
As to why IBM didn't maintain its market share in the face of competing PC compatibles, that's kind of an open question that business schools love to ponder. In any case IBM's stockholders blamed CEO John Akers and fired him in 1993.
If you're really curious here's a HBS case study on IBM under Akers:
http://www.hbs.edu/faculty/Pages/item.aspx?num=12799
I think the gist of it is that IBM in the 80's was still predominantly a mainframe company, and while Akers made admirable attempts at reorganizing it to be more nimble, because of incompetence, institutional inertia, or other reasons, he simply did not succeed before the competition won out.
Others here have talked about how IBM lost control of the original PC BIOS. I wanted to mention a few points about what they did next - the PS/2 and OS/2.
By the mid-eighties it was clear that the PC platform was a massive seller and the PC clone industry was ramping up fast. The 8088/8086/80286 processors being used were all 16-bit designs and so the 8-bit and 16-bit expansion bus connectors that IBM had developed were acceptable. They were, however, a pain to use as you had to manually configure each card and make sure they didn't clash with each other. And pretty much everything - floppy controller, hard disk controller, video card, serial port, parallel port, memory etc - were on expansion cards. It wasn't unusual to have half a dozen expansion cards in your PC and trying to get them all to co-operate was tedious, frustrating and frequently impossible.
So it's the mid-80s. IBM had lost control of the sole piece of intellectual property it owned in the original PC. At the same time, Intel had announced its latest processor - the 32-bit 80386. It hasn't just bigger and faster, it had a clever memory management unit that allowed it to multi-task programs in a way that previously had been impossible on PCs. It was going to be huge.
IBM wanted two things. First, it wanted to take back control of the PC hardware market and second it wanted a new operating system that could take advantage of the capabilities of the new processors that were coming out. The Xerox Star and the Apple Macintosh showed that graphical interfaces were the way of the future, and processors like the 80286 and 80386 showed that DOS's 1MB memory limit was lagging behind processor capability. So IBM started working with Microsoft to develop OS/2, a completely new operating system that would take advantage of the power of the new Intel processors in a way that DOS never could.
To go along with OS/2 IBM developed a new line of PCs, the PS/2 line. These used a completely new expansion bus - MCA - that came in 16-bit and 32-bit versions and that could automatically configure the cards. This might not seem much today but, back then, this was a big deal. The bus was also fast and was clearly well designed. The PS/2 also introduced 3.5" disks to PCs as well as new video cards (MCGA and VGA) and new connectors for keyboards and mice.
This all meant that if you wanted to buy a PS/2 you couldn't bring across pretty much any of your existing kit. You needed a new keyboard, new expansion cards, a new monitor, everything. You needed fewer expansion cards as most of the basic functionality was now implemented on the motherboard rather than on plug-in cards but, nevertheless, it was a big deal.
Plus MCA cards were expensive for two reasons. First they were relatively small that meant manufacturers had to use the (for the time) relatively new and expensive surface-mount components to fit everything in. More importantly, IBM had significant intellectual property in the interface chips that couldn't easily be circumvented. You, as an expansion card manufacturer, had to pay a license fee to use it.
When IBM launched the PS/2s in 1987 they did so into a market absolutely awash with PC clones. Compaq had already beaten them to the punch with launching a PC with an 80386 so IBM was late to market with that flagship processor. Compaq, and other clone manufacturers, were also producing PCs that were faster than the PS/2s were.
Moreover OS/2 was also late. The text-mode version came out a little after the PS/2 launched but the GUI version was very late. Applications were few and far between at first as well.
PC buyers were then left with a choice. Most of their applications were written to run on DOS. They could spend a lot of money on a PS/2 to run DOS on, or they could spend less money on a Compaq to run DOS on and run it faster.
Later, a consortium of clone manufacturers produced the EISA bus which was a somewhat clumsy 32-bit expansion of the 16-bit ISA bus but that was cheaper for manufacturers to build than MCA. There were a few clone manufacturers who also produced MCA machines (under license from IBM) but there was never enough to form a critical mass significant enough to kill off the ISA bus. Instead, new specialist buses (eg, VESA) were developed to provide very high-speed connections to video cards but most of the rest was left on 16-bit ISA. It was only really the launch of PCI in the mid-90s that marked the end of the ISA bus.
The biggest stuff-up, and I remember it clearly, was producing a motherboard that only accepted proprietary cards. It was a competitor to the ATX configuration that accepted a PCI card. (Edit : They called it MCA). They thought they controlled the market such that they could force clone manufacturers to pay them royalties to produce 'IBM compliant' PC's.
They were wrong.
People recognized that you would pay twice as much for that hardware configuration, and very soon after, there were less options available that suited that bus. By the time they completely changed their configuration to meet the intel motherboard format, it was way too late.
Edit :
This explains the strategy, and not so much the outcome. 1987 is when it all went pear-shaped.
IBM got caught in a paradigm shift. Their business model prior to releasing the PC was based on a fairly closed ecosystem, where their revenues were based on hardware + software + support + licensing. The PC was an adjunct to their mainframe business, geared more for small business than individuals.
They completely underestimated the demand, and didn't see that it was really a commodity, consumer goods business. Their inabilty to supply computers to meet the huge demand, coupled with a mainframe view of IP, created a market where it was profitable to reverse engineer to avoid paying royalties. IBM had no experience in consumer goods, where prices are market driven. Companies like Microsoft (operating systems and software) and Dell (hardware) were able to have huge success in exploiting those weaknesses
For those of you wondering, BIOS means Basic Input Output System. It is the thing that lets you choose your operating system(Windows 7,8,Linux) when you boot up your system. It also does a self check to make sure everything is good abd running.