Stock Market is not gamble. When you invest in IPO that goes directly to company. Company spends that amount for expansition. That amount goes to economy.You will invest in IPO only if you can make profit. So after IPO company start trading in secondary market.This way whole cycle works.