It is connected to CO2 the whole time, providing a constant pressure. Over time CO2 will equalize in the headspace and beer. CO2 dissolves in beer easier at colder temperatures, which is why you need less pressure with colder temperatures, and much higher pressure if you were to carbonate at room temp. When you pull the lever it just draws beer from the bottom of the keg. The pressure in the keg forces the beer out once you open the tap valve by pulling the lever. The constant pressure from the CO2 tank keeps steady carbonation. If you were to carbonate the beer, then remove the CO2 line, over time you will lose carbonation due to increased headspace since pressures will always equalize. You will lose serving pressure as well. This is all why it's important to keep CO2 on it at all times.
If you're wondering about hand pumps. Those bring in outside air to keep enough pressure to dispense the beer. This also oxygenates the beer, making it taste terrible after a few days or so.
Hope that helped.