In order to maximize profits, a firm should produce as many units as possible, but the costs of production are also likely to increase as production ramps up. When marginal profit is zero (i.e., when the marginal cost of producing one more unit equals the marginal revenue it will bring in), that level of production is optimal. If the marginal profit turns negative due to costs, production should be scaled back.