The purpose is to serve the public, full stop (including consumers, employees, shareholders, other citizens). The mechanism is the free market, not capitalism, and the free market requires free competition.
Capitalism is one tool in the free market toolbox, and it works very well in many ways. One way this tool doesn't work well is that it leads to monopolies, which stifle competition, which hurts the people listed above.