Keeping carpet clean is a very big challenge itself. Perhaps this is the reason why most people opt for lemon it flooring, because it is just much more easier to keep clean.
Carpets are that much more difficult because they have fibres and they are an apparel so therefore they need to be vacuumed and shampooed when required.
If you have pets around the house that makes this job 10 times more difficult because of pet hairs, as you know these can get everywhere.
The best way to clean carpets is first apply hot water not warm water hot water and let that soak in, then apply aggressive apparel soap and rub that in using a brush.
After you have let this soap set in the carpet for a number of hours, dry it off.