Hard water contains calcium and magnesium salts. When soap is treated with hard water, then the calcium and magnesium ions of hard water react with soap to form an insoluble precipitate called scum. The scum is formed because the calcium and magnesium salts of soap are insoluble in water.