Soaps are sodium or potassium salt of long-chain fatty acids.
Fatty acids such as palmitic acids and stearic acid can be used.
Soaps containing sodium salts are made by heating fat with an aqueous sodium hydroxide solution. This is referred to as saponification.
Chemistry of soap
One end of the soap molecule is hydrophilic which is polar head and binds with water, while the other is hydrophobic (non-polar hydrocarbon tail) and binds with grease.
Diagram (a) is showing grease on the cloth, diagram (b) is showing stearate ions arranging around the grease droplet and diagram (c) is showing grease droplet surrounded by stearate ions (micelle formed).
The oil droplet surrounded by stearate ions is now sucked in water and removed from the dirty surface because the polar groups can interact with water.
Soap aids in the emulsification and removal of oils and fats. The globules' negatively charged coating prevents them from clumping together and forming aggregates.