Businesses Need Capital
The stock markets operate daily and exists is so that businesses can gain capital (money) for business activities. Initially, a business offers an IPO (Initial Public Offering), with the help of a brokerage firm, and this initial offering of business shares can be thought of as a business selling partial ownership of itself to the public. Then, said business might want to 'go public' (issue an IPO and become a listed company on a stock exchange) to raise funds for investment or other expenditures.
Once a business has issued an IPO, the stock is listed and can be traded through a common stock exchange, such as the NYSE or the NASDAQ. These stock exchanges operate to allow investors to change investments, by buying and selling them to other investors. This is where the price of the investment stock / security is 'decided.' Buyers and sellers come together to determine the price of the stock, based on the attractiveness of that stock pick as compared to other stock picks. This is why stock markets fluctuate - buyers and sellers are constantly deciding on a fair price for the stock, based on the latest possible information about the stock, the business, the economy, and other stocks.
Efficiency and the Stock Market
Once a business has issued an IPO, they no longer get any cash directly from the purchase or sale of their stock. Instead, secondary markets, like stock exchanges, serve to allow capital to flow to areas of high yield. In other words, investors are always seeking the most profitable investments, and bid up the price of productive investments, while investors ignore unprofitable stocks thus pushing the price lower. Remember: a company won't receive any money for the transfers of stock amongst investors, but still has incentive to keep the stock price high. High stock price not only pays well for company managers, who are given stock options as part of incentive packages, but also signals investors that the stock is valuable and the company solvent. The stock market, then, moves capital from areas of low yield to areas of high yield through individual investor's search for high-yielding stocks and securities, and further, the stock market constantly seeks to reward companies that achieve high returns by pushing the price of company stock up, benefiting stock owners.