The compressor circulates refrigerant and raises its pressure so heat can be rejected outdoors. When it stops working properly the system loses cooling capacity entirely, and because a compressor is the most expensive single component in a residential air conditioner, the diagnosis deserves more scrutiny than any other repair.
A significant share of suspected compressor failures turn out to be something else: a capacitor, a contactor, a start component, a wiring fault, or a control problem. Confirming which one you actually have is the difference between a modest repair and a major decision.