The action of cleaning of oily dirt by soap is based on presence of hydrophilic end (i.e ionic part ) and hydrophobic end (i.e. hydrocarbon part).
Cleansing action depends upon the micelle formation.
When soap is added in water, soap molecules form micelle in such a way that the hydrophobic part is in contact with oil or grease droplets and hydrophilic parts remain out of the droplets so that it can interact with water.
The oil droplet surrounded by hydrophobic chains is pulled in water and removed from the dirty cloths.