Your friend shows a fundamental misunderstanding of the nature and role of the stock market.
Investors buy stocks (claims of ownership over that firm) for a myriad of reasons, but the primary reason is because they wish to be part of that company and desire a claim to that firm’s future profits (takes the form of dividends). Firms choose to sell claims of ownership (stocks) because they need additional resources in order to fund R&D projects, purchase new and more productive capital goods (which will elevate the productivity of labor and therefore real wages), ect. This market transaction, like all market transactions, is mutually beneficial (ex ante) and therefore constitutes a positive-sum game.
Now it is true that investors, often referred to as “speculators” (though all entrepreneurial endeavors are inherently speculative), purchase and sell stocks in secondary markets because they believe that those assets are either overvalued or undervalued, and hope to earn a capital-gain/avoid capital-losses. In this situation, one party will be right and one party will be wrong. At a superficial glance, this aspect of the stock market appears to be a zero-sum game, but the buying and selling of assets based on expected valuations actually leads to the efficient pricing of those assets (sets the prices of those assets in accordance with actual fundamentals).
This tells the market the true value of a firm and its assets, which provides vital information for other investors and financial institutions. This process may reveal, for example, that a firm has bad managers who are inefficiently employing the scarce resources entrusted to them, and this will lower their stock prices, which, in turn, will allow a more efficient firm to come in, buy the company at this cheaper price, replace management, and use those resources more efficiently.
All of this indirectly serves the needs of consumers and assures optimal allocation of scarce resources. Additionally, there are times (often referred to as “bull markets”), where there are more who wish to buy rather than sell due to general economic growth and productivity gains. This will cause the valuations of stocks in the stock market to rise in the aggregate. This situation is clearly a positive-sum game, again in the aggregate (most individuals are making capital gains, and/or most firms are offering higher rates of return [dividends]).
But your friend is at least partially right in one respect. The stock market is unlike other markets insofar as it does not aim at the direct satisfaction of the subjective values of consumers (doesn’t produce final goods and services); it satisfies such values indirectly by funding the firms that actually produce final consumer goods.