Great question with an interesting history.
The barrier between the flight deck and the cabin of commercial aircraft is engineered to blow out in a controlled fashion upon sudden decompression like the other barriers discussed in Jan's answer.
However, after 9/11, the FAA mandated reinforced doors to prevent unauthorized access. These doors are much heavier than their predecessors, and the security requirements basically dictate that they be one single hunk of material.
Now, consider a decompression event in which the big, heavy door gets rocketed one direction or another. Bad news for anything or anyone in its path:
The pressure differential and the force on the sealed cockpit door
might be too much for the frame structure to handle if the cockpit
depressurizes first. Passive and active internal venting (dado panels)
may malfunction, get clogged by flying debris, or simply not react
fast enough to relive [sic] the pressure differential on the security door.
A loose, heavy, armored door can be much more dangerous than no
door at all (or light door), as it could seriously injure or kill the flight
crew, jam and/or destroy flight controls, damage and destroy flight
instruments, and create mayhem in the cockpit. Such a scenario is
incredibly dangerous, as it may prevent emergency descent. The rise
of pressure differential and the force across the cockpit security door
may well be much quicker than the designed venting system is
capable of handling.
A solution was needed to nearly instantaneously unlock the door when a major pressure difference was felt. Enter the decompression sensing module, some variant of which is almost universal at this point. It integrates with the other components of the flight-deck access system and can unlock the door in a small fraction of a second:
In 2001 the commercial aircraft OEMs needed a solution to rapidly unlock the cockpit door in the event of a decompression event. NAT Engineering developed an electrical solution that responded to a decompression event in the millisecond range. In a matter of months it was taken from concept, through engineering design, computer modeling, prototyping, R&D testing, formal qualification testing, and into production for delivery to the OEMs. The NAT electrical device included integration of control for the keypad, thus providing for a secure keyless entry solution.
A fun thing about the DSM is that one way to test it is by shooting it with a high-powered handgun loaded with a blank cartridge. Makes for an interesting day in the lab.