Why do soaps not work in hard water?
Soaps are sodium or potassium salts of long-chain fatty acids. Hard water contains calcium and magnesium ions. When soaps are dissolved in hard water, these ions displace sodium or potassium from their salts and form insoluble calcium or magnesium salts of fatty acids. These insoluble salts separate as scum.
This is the reason why soaps do not work in hard water.