A soap molecule consists of two parts:
A long chain hydrocarbon tail. It is hydrophobic in nature.
Head: It is hydrophilic in nature.
When soap is added to an oily or greasy part of cloth, the hydrocarbon part of soap dissolves in oil, keeping the head away from the oil. Big molecules of oil and soap break by rubbing into small emulsified oil droplets in water, which are washed away by stream of water. The soap molecules which form micelles assist in dissolving the dirt in water, thus, we can wash our clothes.