Buying stock absolutely provides value. Your cash is transferred to the seller, who then uses it in some way that is valuable to them. Over the big view of the market, some of that cash goes to funding companies through IPOs and later funding rounds, even if you don't participate in them directly.