It all starts when a company wants to raise money to invest in something they think will be profitable such as a new manufacturing process, more production capacity, or a new product. The company can raise money a number of ways, but the two most popular are to borrow the money or sell part of the company. Borrowing the money is usually done by issuing a "bond" which is a promise to repay the borrowed money with interest.
The next most popular way for a company to raise money is to sell "stock" in the company. This is essentially selling a bit of the company, and it sometimes carries a promise of getting a split of the profits when there are profits to split. Stocks are also called "equity" because the owner of the stock has equity, or part ownership of the company.
When a company is formed, or incorporated, it sets up a certain amount of stock which is worth about as much as the paper it is printed on--stock in its infancy carries no real value. When the original owners of the company need to raise money, they have to find good natured individual investors who are willing to invest in small but risky companies, and the owners have to sell this stock person by person, one person at a time. A share of stock signifies the holder owns some fraction of the company and possibly allows the owner to enjoy part of the profits of the company. The stock may have a "face value" given to it when the company was formed, but you couldn't walk into a grocery store with $10 worth of this stock and buy a loaf of bread.
As the company becomes even larger and needs to raise even more money (usually several hundred million or billions of dollars), even more stock will be offered on the open market. This is when it gets interesting. An initial public offering, or IPO, is made of so many shares of stock at a predetermined price of say $15 a share. People who invest in the stock market usually read the Wall Street Journal looking for initial public offerings. At the moment the stock is sold to a shareholder during the IPO it is worth its selling price of $15 a share (in this example). At this point the stock will start trading publicly on the New York Stock Exchange or the NASDAQ. Now you can turn around and sell it for $15 dollars to someone else and then go buy a loaf of bread, if someone is willing to pay you $15 dollars for it. The stock has now gone from being held by a few investors and owners of the company (or closely held) to being publicly held by thousands or millions of owners who can sell it more easily because it is being traded through stock exchanges such as the NYSE or the NASDAQ.
As the stock trades hands, the people buying the stock now determine the value of the stock by what they are willing to pay for it. Sometimes the price of a stock that sold for $15 a share at its initial public offering may drop like a rock. Other times it may skyrocket. The price of the stock is set by many, many people trading it in an free and open market. And even though a person buying a share of stock may be a hundred times removed from the person originally buying the stock at the IPO, that person still owns some teeny, tiny fraction of the company.
In order to purchase stock, you have to set up a trading account with a company like E-Trade, TD Ameritrade, Scottrade or Wells Fargo. You will need an initial deposit, such as $500, which you will then use to purchase stocks. It typically costs about $10 per trade to both purchase a number of shares of a stock and sell a number of shares of a stock. The individual stock you purchase and how many shares you purchase is determined by you, the account owner.
You make money with stocks in one of two ways. The first is with the increase in the price of stock you own, but you have to sell the stock in order to "realize" the earnings. The second way to make money is with dividends. You can use sites like Yahoo! Finance to research a particular stock and find out if they pay dividends and how much they pay. Not all stocks pay dividends. Dividend payments for stock you own will show up in your trading account typically once every 3 months.
Trading stocks where you "buy low and sell high" is just like trading baseball cards. When stock is traded on the open market, the only reason it is worth so much is because there is someone out there willing to pay that much for it. No magic, no mystery.