On the older cars they were engine (belt driven) to inject air into the exhaust to help lean burn hydrocarbons or unburned gasses and to help the catalyst. In the modern cars they are usually electric pumps that mainly work on cold start up, to inject air into the exhaust before the catalytic convertor and help bring the cat to operating temperature quicker.
Their secondary purpose is to collect moisture, make noise, and cost you money