In a way this was because the phone didn't utilize Microsoft's strengths effectively enough to acheieve consumer success, as well as a general strategic problem with Windows and it's design in general.
They should have made the first release basically an XBox phone if they wanted to get consumers on board. Gamers are a target audience that would be willing to make sacrifices to jump onto the platform and establish a user base, which is required to develop a decent ecosystem.
The whole 'Metro' interface has really been a failure for Microsoft as well. They should have simply stuck to Aero or a derivative of it, and kept mobile and desktop computing separate as Apple has.
And of course there's the whole issue of timing. Ballmer didn't seem to take iPhone seriously while Google did and they took immediate action to establish a viable alternative. Had Microsoft had their eye on the ball, it very well could have been them dominating the smartphone market. Or at least they could have been a third platform that actually survived.
They could have been successful if they wanted to just make a phone, but they wanted to make the phone on their terms.
Even after getting my 8.1 device axed from the W10 upgrade list, and being pissed off about it, I did bought an W10 device.
My W10 device still gets updates, while my 1 year old LG is stuck on an random 2017 patch level.