Patents on machines are legal, patents on speech are not. You can’t patent Obama’s latest public appearance or a mathematical proof. Those things are covered by copyright laws (and followers of this blog know that those are flawed as well).
So why are software patents illegal? They are recipes which tell the computer what to do. You can’t patent recipes. Therefore, it should be impossible to file a patent on software.
The long version is here: 1 + 1 (pat. pending) — Mathematics, Software and Free Speech (Groklaw). The article explains why lawyers often get confused by computer terms, how this is bad and how to stop them.