The stock market is not a zero-sum game. Money-now is worth more than money-later to companies offering stocks, who know how to earn more money with that money. Long-term strategies simply take advantage of this fact to make long-term gains. Investments are just codified strategies on what ways you can put your idle money to work in someone else's hand.
Buying an index fund full of stocks at their current market price is no more illogical than running code you didn't write yourself. It's way way less work, it probably works better.
Better yet, trusting someone else's market price is much easier than trusting someone else's code because of the thousands of black-hat investors searching for profitable vulnerabilities in the market prices.