It's usually not the purpose of a company. It may be what shareholders want, but they are not the company. The purpose of a company is whatever the founders of the company decided what it would be. Successful companies will have often have goals that lead to the company making money, like Apple does. But the primary goal of Apple, for example, is not making money.
You can start a cake shop with the goal of making the best cakes in town. If you fulfil your goal, then you are bound to make money as well, as a happy side effect. If you start a cake shop with the goal of making money, you will likely fail if you try to optimise the profit per cake instead of optimising the quality of the cakes.