To maximize profits a firm need not sell the output at the highest price. As a matter of fact in most cases trying to increase the price will result in a loss in revenue and may ultimately lead to a decrease in the profits made. Selling at the highest price may be possible only in the case of a monopoly or where the output is an essential product and has very little price elasticity of demand.
We usually consider a market with perfect competition for the analysis of the optimum price to be charged and the optimum quantity to be produced. In perfect competition the price at which the output has to be sold is its marginal price.
As there is an unlimited demand for the output, the producer can manufacture as much as it likes but it can sell it only at the marginal price. The higher the production, the higher are the profits made.
There is one rule that is always true with regard to maximizing profits. It is true for every product in every market structure. The rule is that a firm maximizes its profits when it produces and sells the quantity of product at which the marginal cost of producing the product is equal to the marginal revenue gained when the product is sold (the MC = MR point). A firm must adjust its price so as to produce at that profit maximizing point.
If a firm raises its price above that point, it will sell fewer of its products. This will cause the firm to make less profit than it would have at the lower price. The firm must then lower the price so that the equilibrium quantity for the product reaches the MC = MR point.