Hardness of water is primarily caused by the presence of dissolved calcium and magnesium salts, which form insoluble precipitates when soap is used, making the water "hard." Sodium and potassium salts do not contribute to hardness in water, while lead and copper salts are not common contributors to hardness.