Where does soap come from?
To make soap, we take oil or fat, and chemically add something to one end that loves water. Lye loves water. Lye is sodium hydroxide, a very powerful alkali. You can tell when a substance is strongly attracted to water because when it reacts with water it releases heat. When you add lye to water, the water gets very hot.
An alkali is the opposite of an acid. Acids and alkalis react strongly to produce salts. A fat or oil is three fatty acids, attached to a molecule of glycerin. Adding lye to the fat allows the alkali to react with the fatty acids. The fatty acids are broken away from the glycerin, and react with the lye to form soap. The glycerin is left behind.
Soap – sodium stearate
The sodium part of the lye is now attached to the long chain of carbons that used to be a fatty acid. The sodium is still strongly attracted to water molecules, and the fatty acid end of the soap molecule ends up on the other side of the water surface, either in the air or in the oil.