As Newton's Law states "things in motion tend to stay in motion." Thus a motorcycle helmet is designed to work like a shock absorber when the bike rider's head tends to stay in motion during a fall or crash when it is traveling a certain speed.
DOT motorcycle helmets are usually made up of four components; an outer shell of a rigid material, a liner made of a crushable material, chin straps, and an inner padding for comfort and fit. When called upon to perform its function as a rigid outer shell adds a load spreading capability and prevents unexpected objects from penetrating the helmet. One could say it is similar to an additional skull, but more impenetrable.
The liner, usually made with expandable polystyrene, absorbs an appreciable amount of energy of an impact by crushing. The chin strap, which of course must be properly buckled and adjusted, and the inner padding helps keep the helmet and position during a fall or crash.
The most important function of your helmet is to save your life when all your skill, judgment and luck fail to keep you from harm. Since the head his weight and is moving there is energy associated with the moving head. When the helmet, along with the head that is inside impact with an immovable object the hard shell starts to absorb the energy generated by the falling helmet (head) and spread it over a larger portion of the helmet and the internal foam liner.
As the foam liner starts to crush and break up it uses a lot of energy presenting it from reaching that valuable head inside. Now depending on how fast the head is moving, and how big, heavy immovable the object is the faster the head slows down and the more energy is present. As a matter of fact, everything slows down very quickly. As Sir Isaac Newton observed, "things in motion tend to stay in motion" a helmet can effectively reduce the speed of that valuable head by breaking and crushing and thereby reducing the amount of energy transferred to the intelligent brain. In much less time to read the above this process takes but milliseconds to turn a potential lethal event and to a survivable one.