What is the function of water softener?

What is the function of water softener?

Water softener removes calcium and magnesium ions, reduce water hardness, prevent scaling on RO membrane, boilers and heat exchangers.