To understand how soap and detergent work, it is first necessary to understand the chemistry behind the molecules of detergent, water and unwanted particles such as oil and grease. All molecules have a particular polarity, which is a charge. This charge affects how the molecule will bind with other molecules. Water, for instance, is considered a polar molecule with a negatively charged end as the electrons in its molecular structure are distributed unevenly. This means that water can bind with other water molecules because of its polarity. As an example, when you pour a glass of water into a glass of juice, they mix and will not separate, because juice is mostly water. By the same token, oil particles are considered nonpolar molecules that have no appreciable charge because their electrons are distributed evenly. These molecules will bind with other nonpolar molecules such as alcohol and gasoline. However, if you were to pour oil into a glass of water, the two substances would not mix by themselves. A simple way to remember these associations is "Like dissolves like."
Solids and Liquids
Additionally, it is important to note that substances do not have to be liquid to bind together; many salts such as sodium chloride (NaCl), also known as table salt, will easily dissolve in polar compounds such as water. Nonpolar compounds such as fat and grease can be dissolved in nonpolar liquid solutions such as gasoline.
Binding and Removing
So how does this allow detergent to react with and clean away oil? It’s because detergent has both a nonpolar end and a polar end. According to Chemist David A. Katz, the reason that soaps and detergents are able to clean is a result of their ability to disperse water insoluble (nonpolar) molecules such as oil and grease into solution with water. When water and detergent are combined, they cluster, forming molecules known as micelles. When these micelles encounter oil or grease particles they surround the particle, as the grease is attracted to the center of the micelle where the nonpolar ends of the detergent cluster. The detergent then bonds with the nonpolar oil particle, and at the end of the reaction the micelle is broken down as the polar end of the detergent bonds with the water. The oil particle is then washed away with the water.