Stocks represent a small portion of the ownership of a company. When a company goes public they sell pieces of itself in exchange for money. Those stocks are then bought and sold on a stock exchange the most famous of which is the New York stock exchange.
If you think that people in the future will pay more for the stock than what it is being offered to you at then it is a good deal. Most stocks are bought and sold through brokerages who exist to trade stocks. Getting stock before they go public is something only people with special access such as management or private investors can do.
Fundamentally, the stock market is a gamble. You are putting down a portion of your paycheck, however large or small, on a bet over whether the company will do better or worse in the future.
For an IPO, you are investing in the company in the hopes of long term profit. And the company uses that money to grow themselves, which adds value to the company. Then you sell your shares to someone else, who hopefully wants to buy it for more than you paid in.
But what if the company goes down? If the advertising dries up because the board of the now-publicly-traded company cracks down on less savory users? Or if the price of stocks crash because of manipulation?
Then you lose the money you put in.
So, key thing, only invest money you can afford to lose.
Latest Answers