Surfactants are one of the major components of laundry and cleaning products. They break up stains and keep the dirt in the water solution to prevent re-deposition of the dirt onto the surface from which it has just been removed. Surfactants disperse dirt that normally does not dissolve in water.
It's like oil and vinegar salad dressing. They do not mix unless shaken vigorously in the bottle and they separate almost immediately afterward. The same is true in washing clothes. Surfactants "shake up" the soil which normally does not dissolve in water, making it dispersible and able to be removed with the wash water.
In anionic surfactants the head of the molecule is negatively charged. This particular type of surfactant is very good at removing oily dirt and stains unless you have hard water (water that is full of minerals like calcium and magnesium). The minerals keep the anionic surfactant from working properly. You'll see anionic surfactants listed as: alkyl sulphates, alkyl ethoxylate sulphates and soaps in the ingredient list of your detergent.
If you have hard water, you will get better cleaning results with a non-ionic surfactant. These surfactant molecules have no electrical charge. You'll find these surfactants listed as ethers of fatty alcohols on the label. You may find them combined with anionc surfactants to complement and boost cleaning action.