What does a detergent do when cleaning

Detergents contain molecules called surfactants which improve the mixing between water and other substances, and also give water more penetrative power to lift dirt particles off surfaces.