Patents don't really work in software because a patent is supposed to be a temporary monopoly on a method of implementing something, and in software there's always more than one way to implement something. A patent on, for example, "enabling the user to buy something with one click" is far too broad - it covers any implementation on a relatively trivial idea. That's the fundamental problem with patents today - at some point they switched from being protection of a process for making something to "idea copyright". Now, the broader you can make your patent the more money you'll reap from it.
Patenting an algorithm, if it's truly non-obvious and hasn't been done before is fine in my opinion. The R&D dollars should still be spent, but spent on things that move humanity forward and not nonsense like buying a monopoly on "a process people have done for decades, but on a computer!"