Not all software patents are alike. Some of them actually demonstrate an original, complicated, novel, non-obvious technique, in sufficient fidelity that an engineer, looking at the patent filing can reproduce the secret design, with far less effort then it would take them to do so without the patent. That is an example of the patent providing benefit to society - that merits society providing it with legal protection.
Most don't, though.