Just to play devil's advocate on this, the money in the stock market (i.e. any stock transaction outside of a public offering) is generally not being invested in companies that actually build things, it's getting stored.
Hm? In the stock market, you pay a current stockholder for their share(s). The company sees no money from the transaction. It sounds like what you're thinking of is banking, which is something different.
I was mostly thinking about brokers. If I buy stock and hold it in my brokerage account, doesn't the brokerage use that money and stock to generate even more wealth? For example, they might loan my stock to somebody that wants to short that company.
incorrect. the company sees money from the transaction in several indirect ways. the existence of the market is what enabled the company to go public in the first place.