Airbags work by distributing the force of a driver's impact with the steering wheel column and extending the time of collision, thus decreasing the impulse imparted to the driver and lessening the likelihood of injury. The gas mixture in an airbag leaves the bag on impact, creating a cushion.
Objects in motion have a certain amount of momentum, dependent on their mass and velocity. To bring them to a stop, an equal amount of impulse must be exerted. This impulse is a product of the force exerted and the time it takes.
If an object has a momentum of 900 newtons, a force of 300 newtons takes three seconds to counteract it and bring the object to a stop. The same concept is used by boxers; when they take a punch, they allow the blow to move their head back, lessening some of the impact. The airbag exerts a small amount of force, in turn distributing the force of impact over the steering wheel column rather than the driver's body.
The airbag is triggered by the car's accelerometer; if the car is going fast enough and hits something, the accelerometer registers it as an impact rather than as braking and triggers the airbag's release.