Stocks were created originally to make it easier to pool large amounts of capital to finance expensive ventures. Before the invention of stock, such ventures were possible only for very wealthy individuals, families or governments. However, the nature of large, expensive ventures is that they are risky and can result in financial loss. Society benefits from the stock markets though, because without them, the range of possible endeavors that a society can take on is far more limited. It can be argued that many of the advances humanity has made through commercial activity would not have been possible without the risks taken as part of stock investment.
en.wikipedia.org