People originally used soap for shaving, but then realized mixing oils, fatty acids, and perfumes created a more enjoyable shave. Shaving cream was developed, with water as the main ingredient and three important acids - stearic, coconut, and myristic acids. These acids control surface tension, pH, and help create foam. Other ingredients like triethanolamine, sodium/potassium hydroxides, and glycerin are added to make the solution soluble and help the cream retain moisture and stability. To make shaving foam, essential oils and acids are heated and mixed, then cooled before adding water, glycerin, and perfumes.