If the company has done well in a year and made a profit, some of it goes into investment for the growth of the company, and some of it distributes to shareholders.
If you think about it easily, it's similar to the interest paid by the bank
You can easily check each company's dividend history here (Apple Inc.)

If you want to study more, please visit Dividends: The fundamental of Stock Investing?

1. Cash Dividend: It refers to a company distributing cash to shareholders based on the number of shares. It's announced how much the company gives per share.
For example, if a company decides to pay a dividend of $0.1 per share and the price per share is $10, the dividend rate is 1%. If we had 20 shares of this stock, we would get $2 in dividends, right?
2. Stock dividend : Giving stock instead of cash. Let's say a company pays 1 share for every 100 shares.
But if we only have 50 shares, which is less than 100 shares, then half of the shares will be allocated? No. Since 1 share is the minimum unit, 0.5 shares are distributed in cash