Because the stock market is needlessly complicated in comparison to a lottery ticket. Stocks should be simple. I purchase a certain amount of stock at a certain value. If there are y shares available and I purchase x shares, then I should technically own x/y of the company, and I should receive an appropriate cut of the profits in the form of a dividend until I sell my shares. That's pretty straightforward.
But then, somebody figured out that when a 1,000 people each have their money invested into a 1,000 different companies, then when a company fails, the person who owned stock in that company loses everything. Better to spread your eggs out, right? So they created things like mutual funds and index funds. The 1000 different people don't own shares outright. Rather, they own pieces of shares with each other. When 1 company fails, they all take the same hit, but nobody goes bust. But now it's getting complicated.
And then, somebody figured out a way to bet on the behavior of a stock. They can pay insurance premiums and if the stock does what they want, then they win big. But nobody has the kind of money available to pay out those massive insurance claims, so the companies that put out the insurance policies borrow against the futures of the massive indices of stocks that they own. They're betting on a bet. And the rabbit hole only goes deeper. It gets so convoluted and reckless, that it's truly baffling that nobody has been tarred and feathered yet.
And all of this is predicated upon the notion that if you hand your money over to a stranger, then that stranger will do everything in their power to increase that money for you, which makes no sense whatsoever. There's nothing really stopping that stranger from just letting you hang as they abscond with what they managed to fleece out of their investors.
Compare that to the lottery. With the lottery, I choose what numbers to play. I choose what scratch-off tickets to buy. I'm told up front what I stand to gain, what I stand to lose, and what my odds of winning are. Nobody is betting on the outcome of a lottery drawing other than the people who purchased their tickets. The Lottery, the casinos, horse racing, sports betting, dog racing, etc... is more honest with the consumer than the stock market. A bookie oftentimes has more honor than a broker. So I'll bet $2 once in a while and I'll let the rich people scrabble for each other's wealth in the stock market. Sure, they'll win much more than I ever will, but I won't be a miserable retch, motivated solely by the idea that money solves everything.