A long time ago, humans ran businesses with just their money. The businesses they ran were small and they grew the businesses only with their own profits. However, not all businesses can be built with your own money. What if you wanted to build a new factory that costs more than a million dollars? Banks won't lend money for young companies and your friends won't have that much.
In the 15th-16th century as the Europeans started exploring Asia and Americas, the big explorers felt they needed a lot of money and their kings were not providing them anymore. The wealthy guys demanded a lot of interest. Thus, they felt they need to raise money from a bunch of common people. Thus, in 1602, the Dutch East Indian company became the first company to issue shares of its company in the Amsterdam Stock Exchange and get traded on a continuous basis.
What is a Stock?
Stocks in a company provide you a share of the company's future profits in return for the capital invested. For instance, if you buy 1 stock of Apple now, you will be assured one-billionth of Apple's profits in the future (as there are almost a billion such stocks that Apple has issued now).
Listing: In a stock market, 1000s of companies are listed and these companies (called public companies - as they have given out their shares to common public) pay a fee to the exchanges, along with a promise to provide all important info to the markets. In return they get an opportunity to put their company in the stock market's board & have the ability to get money from people visiting the market. The first time a company's stock appears on the stock market's board is called an IPO (Initial Public Offer).
Brokers: Conceptually, a stock exchange is similar to eBay. These guys allow companies to be listed and connect the buyers & sellers. Since millions of people trade in the market and it is practically impossible for these exchanges to deal with all the individuals, they have assigned brokers who act between the exchanges and the individuals.