Microsoft made a mobile OS that didn't offer a compelling enough alternative to either iOS or Android.
iOS = Locked in ecosystem
Windows Phone = Locked in ecosystem
Android = Alternative to iOS
Windows = Alternative to iOS
On a technical level, Windows Phone devices performed around the same as iOS devices (fantastic), but lacked mainstream apps (the same problem as Blackberry) but without the backwards compatibility with Android apps.
Basically, Windows Phone was doomed to be the "not android, and not iOS" smartphone despite the great technical aspects of the OS.