Remember the price of the good is the value that consumers place on the last unit of the good purchased. The MC is the cost of producing the last unit of the good purchased. If the value that consumers place on the last unit of the good is just equal to the opportunity cost of producing the last unit, then consumers cannot be made any better off by firms producing more or less of the good. All firms minimize costs they produce along the LRAC curve. Perfect competition is productively efficient.
Perfect competition is allocatively efficient.
Monopoly is productively efficient. Monopoly is not allocatively efficient. The difference between the price that the firm gets for its good and the lowest price it would be willing to accept. There are several causes of market failure in terms of markets failing to achieve the efficient outcome. Monopoly is one cause of market failure.