Helmets are designed to absorb the shock of a sudden impact—not necessarily break a fall. During an impact, the energy disperse across the polystyrene shell of the helmet instead of inside your fragile skull. Even the skull is designed to break to help reduce the force on the wearer.
Bike helmets are sporty adaptations of motorcycle helmets. By the time specialized bike helmets emerged in the 1970's, motorcyclists had been sporting polystrene helmets for years. Bicyclists would be perfectly safe donning motorcycle helmets, of course, but they'd find them both heavy and sweaty. Bicycle helmets are lightweight and designed with ventilation to keep heads cool.
Safety isn't guaranteed. Despite rigorous testing standards, no helmet is sure to respond well to every possible form of impact. In general, helmets perform best during impacts against flat surfaces, where the curved, flexible shell can more easily disperse the force.