Companies issue stock because need money to expand their business. At some point every company needs to "raise money". To do this, companies can either borrow it from somebody or raise it by selling part of the company, which is known as issuing stock.
A company can borrow by taking a loan from a bank or by issuing bonds. Both methods come under "debt financing". On the other hand, issuing stock is called “equity financing”. Issuing stock is advantageous for the company because it does not require the company to pay back the money or make interest payments along the way.
All that the shareholders get in return for their money is the hope that the shares will someday be worth more than what they paid for them. The first sale of a stock, which is issued by the private company itself, is called the initial public offering (IPO).
It is important that you understand the distinction between a company financing through debt and financing through equity. When you buy a debt investment such as a bond, you are guaranteed the return of your money (the principal) along with promised interest payments.
This isn't the case with an equity investment. By becoming an owner, you assume the risk of the company not being successful - just as a small business owner isn't guaranteed a return, neither is a shareholder. Shareholders earn a lot if a company is successful, but they also stand to lose their entire investment if the company isn't successful.