What is soap? What does it consist of?
Soap is a well-known solid or liquid detergent. What does it consist of and why does it help to clean one’s skin? It may sound weird but soap consists of quite complicated molecules. Each of these molecules carries a positively charged sodium ion Na+ (with which we are familiar) or a potassium ion К+ (in liquid soap), and a large negatively charged organic fragment (anion).
These anions resemble tadpoles, as they have a negatively charged “head” on the one end, and a long “tail” on the other—a chain of carbon atoms (approx. 15–20 atoms). When we dissolve soap in water, these “heads” readily put on a “watery coat”, just like Cl- ions would do.
At the same time, this long tail of a molecule does not feel comfortable in water and constantly tries to escape. It appears that most molecules of dirt behave the same way, and thus, they are hardly removable with just water. Otherwise happens when dirt gets in contact with soap solution, “like attracts like”: soap’s anions turn tails toward dirt particles, but their heads are left in water. Thanks to such mediation, it's much easier to wash out dirt with soapy water compared to just plain water.
Molecules similar to the one described above are called “salts”: you already know copper sulfate CuSO4 and ammonium chloride NH4Cl. In a solution, salts easily dissociate into positively and negatively ions:
NH4Cl → NH4+ + Cl-
CuSO4 → Cu2+ + SO42-
NaCl → Na+ + Cl-
Interestingly enough, regular cooking salt, or sodium chloride NaCl, the only compound we got used to call “salt”, does indeed belong to the class of salts. It's easy to get confused!
Finally, complex soap molecules are called fatty acid salts. More on them a bit later, however.
What is stearin?
In our case, stearin is the base of a candle. If we replace sodium ions Na+ in a compound from the previous topic by protons H+, we will obtain… stearin—a mixture of so-called fatty acids. Fatty acids feature a specific functional group consisting of carbon, oxygen, and hydrogen atoms on the one end, which makes them belong to acids group. Another end stays the same: a familiar chain of carbon atoms. Thus, by changing just one atom in a molecule, we can get two compounds with very different properties. One of them is able to wash out dirt, another could be used to make a candle!
Why do we need citric acid?
Since soap is salt of fatty acids, and candle consists of stearin (fatty acids themselves). Hence, to make a candle, we need another acid to react with soap solution. The reaction proceeds as follows: citric acid takes Na+ from fatty acid salts and in return provides H+, thus producing fatty acids, or stearin. Stearin is poorly soluble in water, so it forms a viscous sticky residue. After we dry out that stearin, we can make a candle.
Why is it important to dissolve soap before adding citric acid?
In order to turn citric acid into salt and fatty acid salts into fatty acids themselves, we need to create certain conditions, so that nothing would prevent them from meeting each other. If soap is not dissolved completely, significant amount of compound inside of big chunks would not get in contact with citric acid and wouldn't react. Stearin would be produced only on the surface of such chunks and it would isolate the core from the solution as stearin is insoluble in water. Therefore, it is very important to dissolve soap thoroughly in water prior to adding citric acid solution.
Thus, we need heating and agitation in order to accelerate dissolving soap in water.