Really? I think if you list Microsoft's product lines, only a relatively small proportion failed badly. Sure, Zune never took off and their various on-line efforts haven't exactly had stellar results. Still, it's not like MS only makes money on Windows and Office. They also have a very successful range of server products aimed at businesses. Their initially loss-leading efforts to penetrate the computer game market are now doing pretty well. They even make good keyboards and mice.
Now, here's the kicker. Microsoft do effectively give away a couple of things, notably software development tools and IE. They also run Microsoft Research, which is where a respectable amount of serious work on the future of both programming and HCI is going on today. However, these things are done in a way that supports their overall business interests, which is exactly the sort of strategic decision that good management needs to be getting right.
I'm hardly a Microsoft fanboy, as many of my previous posts will confirm, but I don't think they have been anything like Google or Facebook in terms of hit-to-flop ratio in recent years.