People buy stocks (shares) for two major reasons. First, they expect the share price to go up. This is known as capital appreciation. Meaning, if they buy Apple shares at $209, and in 6 months, if the share price goes up to $250, they have made $41.
Second, people buy shares because they expect to get some income from the company, on a periodic basis. This is known as a dividend. Companies pay dividends from the profit they make within a period, or when they sell an asset.