When we try to clean things, whether it’s our hands or our clothes, water is doing most of the work of cleaning by flushing out all the dirt and stuff we’re trying to remove. But adding soap makes the water more effective. Soap does this in two main ways.
First, soap reduces the surface tension of water. Have you ever spilled some water on a table and watched the water sit there as a drop? That occurs because of the surface tension of the water. Adding soap reduces this surface tension and allows the water to spread out and absorb more easily into the things (such as your clothes) that you wish to clean. When something reduces the surface tension of water we call it a surfactant (short for "surface-active agent").
In order to remove the dirt and grease and oil from your hands and clothes, you need to wash them away. But most of us know that water and oil don’t mix. The second way that soap helps the water to clean is to provide a way for the dirt and oil to mix with the water so they can be washed away.
If you remember your chemistry, you’ll know that soap, dirt, oil, and water are made up molecules. There are hydrophilic molecules which are attracted to water. And there are hydrophobic molecules which repel water.
A soap molecule is unique because it has one hydrophilic end and one hydrophobic end. So it acts as a bridge and attaches to a water molecule at its hydrophilic end and a dirt or oil molecule at its hydrophobic end. When you rinse off your hands or your clothes, the hydrophilic end of the soap molecule gets washed away with the water and drags the hydrophobic end (and the dirt/oil) along with it. So the soap sticks to the water and the oil sticks to the soap and it all goes down the drain!
So why does it seem that things get cleaner in hot water rather than cold? Because the oils and fats melt in hot water, which makes them attach more easily to the hydrophobic end of the water molecule. And that makes them easier to flush away with the rest of the dirty water.