Your gain in the stock market is somebody's loss..no?
Not quite. The way the stock market is
supposed to work is that someone buys a stock in a company that
actually makes a product or provides a service (i.e., a "real" v.s. a 90's "virtual" company) and makes a profit from such. Let's say Wrigley (WWY) takes horses' hooves & sugar and turns it into chewing gum--that's "value added" -- people wouldn't pay good money to buy old hooves, but they are willing to pay for a package of Big Red. WWY expands the distribution of Big Red to China and India; more hooves, more sugar, more profits...and so on and so on.
Contrast that "value added" to RE flipping. A person buys a house for $100,000 on Jun 1st; gives it the $10,000 flipper special (GCT, SS appliances, a coat of contractor beige paint) and sells it for $200,000 on Jun 25th. The second person adds $10,000 of Pergo and a back deck and sells it for $300,000 on July 15th.
One is sustainable, value-added, profitable and worthy of investment. The other is unsustainable speculative frenzy. All things being equal, the former is capable of producing a situation where each succeeding holder of the stock has a chance of being better off--the latter will end up with "the greatest fool" dangling at the end of the line.