In my opinion, it is all about value creation. Investments are a positive-sum game. There is money coming into the system from the outside, even if no shares exchange their owners. This can take the form of dividends, stock buybacks or growth companies re-investing and thus increasing their value. But there is creation of measurable value and new money coming into the system. Investing has usually - but not necessarily - a positive expectation value in the long-term. There is risk (volatility) that is rewarded with a certain degree of expected returns for giving up liquidity.
Speculation on the other hand, is at least a zero-sum, if not a negative-sum game. The gains of one person are the loss of another. There may be a time difference between these events with new investors coming in, but in the end, all returns are losses of others. After taxes and fees, this always has a negative expectation value for the entire system, but may come with high variance.
Stocks have both an investing and a speculative component. The former creating a general upward skew in price, the latter adding a random walk component to the expected returns of the whole market.