Clothes become dirty when something get spilled on it or because of human precipitations dirt comes and attaches itself in the pores of the clothes.The cleansing action of soap is determined by its polar and non-polar structures in conjunction with an application of solubility principles. The long hydrocarbon chain is of course non-polar and hydrophobic (repelled by water). The "salt" end of the soap molecule is ionic and hydrophilic (water soluble).
When soap is added to water, the ionic-salt end of the molecule is attracted to water and dissolved in it. The non-polar hydrocarbon end of the soap molecule is repelled by water. The non-polar end gets attached to the dirt or grease fixed in pores of the clothes .
when we rub the cloth the grease portion attached with hydrophobic end dettaches itself from the cloth and hydrophilic end of the soap remains attached to water molecules in soap solution and the cloth becomes clean