Salt absorbs water moisture because it is an ionic compound with strong attractive forces for the highly polar water molecules. This property means that salt is hygroscopic, meaning that it absorbs both liquid water and water vapor in the air. This process is actually the same one that occurs when salt is dissolved in water, except that in this case the salt predominates, so the interacting particles maintain solidity.
Salt has long been prized as both a seasoning and as a preservative. Its ability to absorb water is what makes it a good preservative. Water molecules, like any other molecules in a fluid, are subject to diffusion. That is, they tend to move from areas of low concentration to areas of high concentration. The process of osmosis is one where water moves across a cell membrane. Cells have only a limited ability to control osmosis, and preserving with salt takes advantage of this. When bacteria attempt to consume a salted food item, the salt overwhelms their ability to control the osmotic movement of water leaving the cell to the lower concentration of the salt crystals. This rapidly depletes the microorganism of water, killing it. In this way, drying and salting foods can protect them from decay for long periods of time.