The cleansing action of soap is due to emulsification and micelle formation.
Soaps are basically sodium and potassium salts of long-chain fatty acids, R−COO−Na+. The end of the molecule to which the sodium it attached is polar in nature, while the alkyl - end is non-polar.
Thus, a soap molecule contains a hydrophilic (polar) and a hydrophobic (non-polar) part.
When soap added to water containing dirt, the soap molecules surround the dirt particles in such a manner that their hydrophobic parts get attached to the dirt molecule, and the hydrophilic parts point away from the dirt molecules. This is known as micelle formation.
Thus we can say that the polar group dissolves in water while the non-polar group dissolves in the dirt particle.
Now, as these micelles are negatively charged, they do not coalesce and a stable emulsion is formed.