If you think about what is being traded on a stock market, you can see that the stock markets is a very good way for companies to raise funds. Companies sell their shares on the stock market which provides exposure to wide range of different investors.
The cost of raising funds is far lower for listed companies since there are a lot of active investors that use the stock markets to find attractive and suitable for them investments.