To my (admittedly untrained) eye, I'm not sure what Microsoft could have done differently. It had put forward mobile operating systems before; Windows Phone and Pen both had longstanding iterations. So while I think it's easy to blame Ballmer, it strikes me to some extent that Microsoft suffered a lot of bad luck. It's timing was wrong on some products, and after having won the PC wars it simply didn't know where to go.
It's not *what*, it's *how* and *what for*. Microsoft had everything they ever wanted - complete dominion of the computer industry at the time. At the dawn of the millennium, no one made a move if they weren't sure Microsoft wouldn't or couldn't compete in that arena. A few years earlier, a stray remark from Ballmer brought the tech market stocks down 5% in a single day. They have everything to lose, and nothing to gain.
Apple, Google, and RIM were *hungry*. They each had a vision that didn't necessarily involve dominating the market and instead was more customer focused. They cared about the finer points of their customer's issues. They iterated rapidly.
Microsoft's attempt to grow the computer industry ran into their real desire to simply dominate what existed. If they couldn't dominate it they wouldn't grow it. And that attitude persisted for over a decade, so they became incapable of competing - they didn't have to for years. They still don't have to in their core markets. It's just that those markets don't comprise "all of computing" anymore.