Soap does not work properly when the water is hard. A soap is a sodium or potassium salt of long chain fatty acids. Hard water contains salts of calcium and magnesium. When soap is added to hard water, calcium and magnesium ions present in water displace sodium or potassium ions from the soap molecules forming an insoluble substance called scum. A lot of soap is wasted in the process.