Soap does not lather well in hard water. The hardness of water is due to dissolved calcium and magnesium salts in it. These salts react with soap to form insoluble compounds resulting in the decreases of lather. But detergent do not give insoluble compounds on reaction with these salts. Hence detergent are more effective than soap in hard water.