Helmets are useful as safety gear to prevent injuries in an uncontrolled environment. If you can’t prevent a crash or impact, but you know it will occur, a helmet can prevent or minimize injury to the head and brain.
Human brains can be injured by impact, of course, or by exceptionally violent rotation of the head, when the brain remains stationary, giving blood vessels and nerves a yank. Internal blood vessels and nerves yank parts of the brain around too in different ways, straining the vessels and nerves in the process.
When you crash and hit a hard surface, the foam part of a helmet crushes, controlling the crash energy and extending your head’s stopping time by about six thousandths of a second (6 ms) to reduce the peak impact to the brain. Rotational forces and internal strains are likely to be reduced by the crushing.