The short answer
Dirt comes out of carpet through three things working together: suction, agitation and a carrier, such as water with a cleaner or an absorbent powder. No single step does all of it, which is why a vacuum alone often leaves some soil behind.
Suction
A vacuum pulls loose particles up with airflow. It works best on dry, loose dirt, such as grit, sand and pet hair. Slow passes give the suction more time to lift material from the base of the pile. A full bag or a clogged filter reduces suction, so check it before you start.
Agitation
Dirt often clings to fibers, and brushing loosens it so the vacuum can take it. A stiff brush or a vacuum with a beater bar does this. On some looped or delicate carpets, a very aggressive beater bar can fray fibers, so check the carpet’s care guidance if it’s a sensitive type.
Water and cleaning solution
Water and a cleaner carry dirt in a different way. Soap helps lift oily soil, and moisture helps soil release from the fibers. Without a machine to pull the liquid back out, anything you add has to be rinsed and blotted up again. That’s where many home jobs go wrong, since leftover soap holds dirt in place.
Hot-water extraction
Machines that use hot water pump liquid into the carpet and then suction the water and dissolved dirt back out. That removal step is what many people think of as a thorough clean. You can’t match it at home, so keep the moisture low and rinse carefully.
Absorbent powders
Dry powders absorb moisture and soil from the pile. You work them in, leave them for the time on the label, and vacuum them up. They lift surface soil well and deep soil less well.
Baking soda
Baking soda absorbs odors and can lift a little surface grime. It doesn’t do much to clean the fibers on its own, so it’s better for freshening than for a deep clean. If you’re wondering how to clean carpet stains, a different method may suit the stain better.
Why dirt sometimes comes back
Dirt returns when soap is left in the carpet, the rinse isn’t complete, too much water soaks down into the backing, or the carpet gets walked on before it’s dry. Sticky carpet after a vacuum often points to leftover cleaner. Why does my carpet feel sticky after I vacuum it covers that problem in more detail. For a full routine, see how to deep clean a carpet without a steam cleaner.