The stock market is just a mean of transferring wealth. It won't change anything in the "real world". You're not generating value for anybody by investing in it. If that makes your existence fulfilling, good for you. But I'd just feel a crook.
If anything, ownership should be spread more widely. Suppose the government bought index funds and used it to fund basic income?
Apparently that makes the average Joe a crook? I don't know, I don't see it.
You are providing funds for companies to exist. Companies that pay some of the people, and provide services for other people. You also get a share of the profits.
Certainly, this can be abused, but at the fundamental level, it's a good thing to have businesses that provide value. I like being able to go buy a nice computer when I want one, or going and getting some fast (or slow) food. I also like googling things. All these things are (often) supported by stocks.