What is the function of capitalism?
Capitalism is defined as an economic and political system in which a country's trade and industry are controlled by private owners for profit, rather than by the state.

It functions as an allocation mechanism which generally yields the most optimal results under the Fundamental theorems of welfare economics and prevents issues such as Tragedy of the commons which a communist system would fail to deal with (unless all resources were heavily policed and regulated with knowledge of every consumers utility functions).

Under a pure capitalist system, government intervention in the market place is viewed as harmful.

However according to mainstream economic theory, there is some benefit to have from government intervention when dealing with  externalities, market saturation and responding to Business Cycles.