Historically it is more the case it came into existence to finance piracy on the high seasMy understanding/opinion of the purpose of the stock market is (1) to allow companies that need capital to borrow it, and (2) to allow investors to invest in companies they think (financially) worthwhile. The company needs to put forward a good case as to why it needs and how it will use the capital, otherwise the investor will not wish to invest. That seems a very sensible arrangement.
However, it is very open to manipulation and thus in need of regulation. It seems that the purpose could better be met if the regulation included a requirement that any stock held should be held for at least a year (under penalty of very high tax if not). That would help ensure that the investor really was investing in the company, not in the possibility of short term gain, and companies would have greater stability.
At least it could be argued, it fulfils it's original purpose