If we consider a circuit with a large inductance, possibly one using a magnetic relay. At the instant the switch is opened, the current through the coil is changing at maximum rate, therefore the back emf induced in the coil is also at maximum.
This emf is applied to the air gap between the switch contacts and ionises the air, producing a spark which the burns the contacts. This increases their electrical resistance and radiates energy which may cause interference, therefore sparks must be suppressed. Good design of switch contacts can help, but connecting a capacitor in parallel with the switch is the best method of eliminating sparking.
When using a capacitor the energy released by the coil charges the capacitor instead of ionising air. When the switch is closed again the capacitor discharges.