Wealth is not just money in someone’s pocket / taxes paid it’s the actual capital of humanity.
Suppose I found a way to make synthetic oil for 1$ per barrel from atmospheric CO2 and published it. Now I can’t capture that wealth and Exxon’s and many other companies stock tanks so it looks like global wealth decreased. However, soon everyone across the globe can now buy more with their money. Lowered transportation costs for potatoes means potatoes cost less in a very real way.
This is why patents expire, everyone gets richer when they do.