The removal of solid deposits from the surface of clothes requires energy:

This energy can be reduced by the addition of a surfactant to the water.  The surfactant sticks to the solid surfaces as they separate, so less work is required to remove the solid:

When agitation from the washing cycle is stopped, how is re-deposition of the solid prevented?  Most solids in water develop a slight negative charge, therefore cationic surfactants accumulate with their head groups at the surface, so there is a strong tendency for the hydrocarbon chains, which have no charge but are hydrophobic, to interact and re-stick the solids back together.

This effect can be reduced by using twice as much surfactant:

The positive charges repel each other, thus preventing re-deposition.  However, using more surfactant increases the cost of the washing powder, so cationic surfactants are not used commercially.

Anionic and non-ionic surfactants accumulate the other way around to cationic surfactants, and therefore provide a cheaper, more efficient method of preventing re-deposition:

If the stain on the clothing to be cleaned is a liquid, such as oil, re-deposition is prevented because the surfactant accumulates at the interface between the water and the oil, with the hydrophobic tail inside the oil droplet.  This keeps the oil in suspension in the water, preventing it from re-attaching to the material.

Some stains are too well absorbed into the fabric of clothes to be effectively removed by surfactants alone.  Enzymes are added to biological washing powders to help remove stains at low temperatures.  The enzymes most often used are a protease to break down protein stains and a lipase to break down fats and oils (lipids).  These enzymes decompose the stains by hydrolysis, and are able to help break down stains which are hard to remove with conventional surfactants alone.