This is actually not true at all. The cost here isn't in the filing of the patents; it's in the nightmarish patent system that results in absurd litigation and related expenses. If the patent system were reformed to avoid this kind of expense, the company would have lower operating costs, which would be distributed in some way. While it's possible I suppose that 100% of those savings would be collected by shareholders as profit, it's much more likely that, like with anything else, the cost reductions would simply contribute to the size of the total pie, which would be split among owners and employees in proportions probably roughly similar to how it's split today.
New York-based law firm Skadden Arps, rakes in over $180,00 a year. But Netflix, Mozilla, and VMware are are all well known tech companies that top the list.
Google is not even in the top 10. http://www.glassdoor.com/blog/americas-15-highest-paying-com...
And it's not like they are going to pay us more if they stop filing patents. In fact, many firms pay a bonus if your work results in a patent (or even a patent application.) Clearly they see some value in them, and they have reasons to.
And this is true of all patents, btw, not just in software.