
Stain removers work purely on chemistry. Water has a property known as surface tension. This means that the surface of the water is attracted to other surfaces. Water molecules are attracted by each other, however on the surface of water there are no other 'like' molecules. This is why they are more attracted to other molecules that they come in contact with on the surface.
Due to surface tension, when a drop of water falls onto your kitchen counter it does not spread quickly. Instead it roughly stays in the shape of a drop. Detergents on the other hand, are surfactants, substances that lower the surface tension of water. These surfactants surround the stain molecule and make it easier for water to remove it from the fabric, allowing it to get washed away. Today synthetic surfactants like sulfonates are used as unlike soap they do not react with hard water to give calcium deposits.
There are some stains that just seem too hard to remove. Stains like grease can only be removed by hydrocarbon solvents. The oxidizing agents attack and destroy the links formed by the molecules of the stain, and the leftover molecules are water soluble and just wash away. There are certain stain removers which have whiteners in them which don't just remove the stain but whitens your clothes? This type of stain remover contains chemicals which absorb UV-light and instead emit a visible-light.
There are three basic ways in which stains are removed -