The answer to 'how does water softener work' is that a water softener is a device that removes minerals like calcium and magnesium from hard water. It does this through a process called ion exchange, where the water passes through a resin bed that attracts and traps the mineral ions. This results in 'soft' water that is better for cleaning, laundry, and reduces scale buildup in pipes and appliances.
Water softeners work by using salt (sodium chloride) to periodically regenerate the resin bed and flush out the trapped minerals. This is an automatic process that happens on a regular schedule, typically once or twice a week. The softener will draw in a brine solution of salt water, which displaces the calcium and magnesium ions on the resin, allowing the resin to be ready to soften water again.