Yes. Insofar as trading helps reveal the "true" value of a stock and thereby helps solving the allocation problem, it creates public benefit. And the companies financed by the equity markets create huge value, of course (parts of which they distribute by dividends or stock buy backs). But if you look narrowly at the gains and losses of trading, it's strictly a zero-sum game (well, negative sum, as the exchanges and market makers take their cut - though that cut in the good old equity markets is minuscule and far, far smaller than in the fancy new crypto exchanges which charge outrageous fees.)