Washing machines have different temperature settings because some fabrics and colors require different levels of heat to be washed thoroughly.
Use hot water for light colors, particularly light colors that are especially dirty. The heat will scald the stains right out of those white items.
Use cold water for dark colors, as cold water reduces the amount of dye that runs from these clothes (so your clothes won’t fade as fast when you use cold water). Cotton items should also be washed in cold water as they are less likely to shrink in cold water.