Soap ions consist of two parts, that is the head that consists of the anion region, ionic and also called the hydrophilic region which dissolves in water. Another part is the tail that consists of hydrocarbon region and its molecule has covalent characteristics. Its also called the hydrophobic region which dissolves in grease or oil(dirt)
The soap molecules will dissolves in water and reduces the surface tension of water. Water wets the dirty surface. The hydrophilic region dissolves in water whereas the hydrophobic region dissolves in dirt such as grease. Grease is lifted off the surface of the material and suspended in water. The tail region emulsifies and breaks up the grease into small drops.
When shaken, the water molecules will attract the soap ions and cause the grease to detach from the surface of the material. The soap bubbles help to float the grease emulsion in the water. When rinsed, the grease will be removed together with the water.