Dividends are a payment the company gives you for owning stock in their company. Owning stock in a company means that you are a partial owner of the company (as small as that ownership may be). Because more than 80% of the companies in the S&P500 pay dividends, you can actually earn money even when the market is down. If you have $10,000 invested in companies that average a 3% annual dividend yield, you will get $300 cash from the company in dividends over the year (usually 4 payments of $75 each). The Dutch East India Company (VOC) was the first recorded (public) company ever to pay regular dividends. The VOC paid annual dividends worth around 18 percent of the value of the shares for almost 200 years of existence (1602–1800).
Companies pay dividends because investing comes with risks and they want to entice you to invest with them. Even good, well-established companies have some risks that owning their stock might not bring you positive returns.