We call water "hard" if it contains a lot of calcium or magnesium dissolved in it. Hard water causes two problems:
The solution to hard water is either to filter the water by distillation or reverse osmosis to remove the calcium and magnesium, or to use a water softener. Filtration would be extremely expensive to use for all the water in a house, so a water softener is usually a less costly solution.
- It can cause "scale" to form on the inside of pipes, water heaters, tea kettles and so on. The calcium and magnesium precipitate out of the water and stick to things. The scale doesn't conduct heat well and it also reduces the flow through pipes. Eventually, pipes can become completely clogged.
- It reacts with soap to form a sticky scum, and also reduces the soap's ability to lather. Since most of us like to wash with soap, hard water makes a bath or shower less productive.
The idea behind a water softener is simple. The calcium and magnesium ions in the water are replaced with sodium ions. Since sodium does not precipitate out in pipes or react badly with soap, both of the problems of hard water are eliminated. To do the ion replacement, the water in the house runs through a bed of small plastic beads or through a chemical matrix called zeolite. The beads or zeolite are covered with sodium ions. As the water flows past the sodium ions, they swap places with the calcium and magnesium ions. Eventually, the beads or zeolite contain nothing but calcium and magnesium and no sodium, and at this point they stop softening the water. It is then time to regenerate the beads or zeolite.
Regeneration involves soaking the beads or zeolite in a stream of sodium ions. Salt is sodium chloride, so the water softener mixes up a very strong brine solution and flushes it through the zeolite or beads (this is why you load up a water softener with salt). The strong brine displaces all of the calcium and magnesium that has built up in the zeolite or beads and replaces it again with sodium. The remaining brine plus all of the calcium and magnesium is flushed out through a drain pipe. Regeneration can create a lot of salty water, by the way -- something like 25 gallons (95 liters).
Here are some interesting links: