Hard water contains calcium and magnesium ions. Water softeners use resin beads, which hold sodium ions. When hard water passes through the resin beads inside the softener, the beads attract and hold calcium and magnesium ions and give off sodium ions. After this process, the water leaving the softener is soft.
Salt water is used to wash the resin beads. The brine solution loosens the hardness ions, which have built up on the resin beads; then the system backwashes and flushes the hardness minerals away. Once again the system is ready to soften more water.