The freewheeling unit allows for an autorotation. Since lift in a helicopter is provided by rotating airfoils, these airfoils must be free to rotate if the engine fails. The freewheeling unit automatically disengages the engine from the main rotor when engine revolutions per minute (rpm) is less than main rotor rpm. Chapter 4 of the Helicopter Flying Handbook provides additional information on the freewheeling unit.
The most common freewheeling unit assembly consists of a one-way sprag clutch located between the engine and main rotor transmission.
The principle of the freewheeling unit can be thought of like riding a bike. When you ride a bike, the wheels will not go slower than the pedals. But, if going down hill, you can stop pedaling and coast without the pedals turning. In the helicopter, the sprag clutch allows the rotor system to operate freely without the drag of the failed engine.
The following videos shows some different transmissions and freewheeling unit combinations from various helicopters. At approximately 5 minutes into the video, you get to see the inside of the unit from a Bell 206.