In order to have an air cooling system in a vehicle, it needs to have a way to remove heat from the air reaching the occupants. Most of these systems, be it in a car or a building, rely on thermal transfer and the temperature changes which occur as pressure changes. AC compressors are the component that builds up the pressure, which increases the heat energy level of the refrigerant.
Without compressing refrigerant, the air conditioning system would only be able to cool down the vehicle's occupants if the air inside the vehicle was hotter than the air outside, and even then, it would be a slow process.
The AC compressor turns on and off as needed, in order to save fuel and power when not in use. It will also cycle on and off automatically, depending on how much cooling is desired compared to how hot the outside air is.
Typical Power Source
Most vehicles have the AC compressor attached to the engine so that it can be part of the serpentine belt system. Because the belt is always being driven, these compressors use a magnetic clutch pulley that allows the belt to feely spin the pulley when the compressor isn't needed.
Alternative Power Sources
Some vehicles use an electric AC compressor that is turned on and off as needed. These are typically found on electric cars and some hybrid models.
Example: AC Delco 15-21469
Pictured above is an AC Delco brand AC replacement compressor for a 2005 Pontiac GTO. It currently has a cover over the inlet and outlet ports (top right, clear-ish colorless plastic) to prevent moisture from getting into and corroding the internal components, and should only be removed to install.
The blue component up and left from the center is the plug for the magnetic clutch circuit connector.
Other Uses for an AC Compressor
An AC compressor doesn't just have to be used for cooling the occupants of the vehicle! In this video, Engineering Explained how the Dodge Power Chiller works. This video was uploaded on July 26th, 2017.
Variable-Displacement AC Compressor
A more advanced type of AC compressor is uses a variable displacement design to reduce the need for or, more commonly, eliminates the need for a clutch. Instead of turning on and off to meet the varied needs of interior temperatures relative to outside temperatures, a swash plate can adjust how much the pistons in the compressor move up and down, and moving all the way to flat will prevent any kind of compression from happening at all.
In other words, if a traditional AC compressor would have needed to be on 50% of the time and off 50% of the time, the variable displacement AC compressor can run at about 50% of the maximum angle at all times, providing a more consistent cooling effect while also never putting full strain on the AC system.