It is legally mandated, and part of the National Electrical Code (NFPA70). NEC is adopted across most of the US.
National Electrical Code 2014
Chapter 4 Equipment for General Use
Article 440 Air-conditioning and Refrigerating Equipment
440.14 Location. Disconnecting means shall be located within sight from and readily accessible from the air-conditioning or refrigerating equipment. The disconnecting means shall be permitted to be installed on or within the air-conditioning or refrigerating equipment.
The disconnecting means shall not be located on panels that are designed to allow access to the air-conditioning or refrigeration equipment or to obscure the equipment nameplate(s).
It's largely a safety precaution to ensure the power is off if someone is servicing the unit.
If your breaker panel is 20' away and within sight of the unit, it's probably acceptable as a disconnect means but of course your AHJ (inspector) will have to agree. If you can't see it, you'll have to put in a separate disconnecting means.