Cleansing action of soap depends on its structure, it has two ends hydrophobic which attracts dirt, oil or grease and hydrophilic end which attracts water.

The dirt is carried by hydrophobic portion which is attached to hydrophilic end which gets attached to water and is washed away.