Patents are an artificial system forced upon us with the hope that they accelerate innovation. Just as you said, the hope there is that it encourages someone to take the risk of making something new with the hope of massive exclusive rewards.
The problem with that hope is that it ignores how innovation happens. There is no reclusive mad scientist working in some dank basement on the next-best-great-thing. That's childish.
Innovation happens through collaboration. You take someone else's work and you build upon it. Bit by bit, people build the next-best-thing.
The current patent system tries to take this into account by creating a lifespan of 20 years or so. But for those 20 years ... you are stifling the potential innovation that can happen by incorporating that new-best-thing into the next-best-thing.
This is even worse for software! A new paradigm arises (Internet, AJAX, Geolocation, etc.), a new set of algorithms become necessary to make things work. These paradigm shifts take years, not decades. As a consequence, innovation is limited to those who created the initial algorithms, since they're the only ones who can build on the most basic work.
Imagine Google created the algorithm/API for getting geolocation from the browser and built it into Chrome, then patented it. Nobody else would be able to do it. Obvious invention you say? Not as obvious as Amazon's one-click-to-buy button. The worst part in this example is simply that while Google may have invented it, there is an almost certain chance that Mozilla/Apple/Microsoft would have been able to make it better within weeks. We are missing out on that kind of innovation for patented software.