Soap contains surfactants that break apart the layers of grease, dirt, grime, and dead skin cells leaving behind cleansed skin ready to start the process all over again.
This process was also used to cleanse hair, as well from grime, dead skin cells, environmental pollutants, and scents picked up from day to day locations. The downsides to using soap was that it stripped away the beneficial oils that keeps hair from becoming dry, brittle, splitting, and unappealing.
Many cultures found that adding naturally occurring oils afterwards helped keep hair from becoming unmanageable. In Indonesia, the use of Coconut oil after washing helped make the hair very silky and moisturized.