The electrostatic interactions between salt cations and the phosphates in DNA backbones serve as the foundation for the precipitation technique.
Positively charged ions like calcium or sodium will be drawn to the backbone of DNA since it is actually a double helix made of two negatively charged phosphate-sugar backbones along which nucleic acids are bound. Ionic salts and DNA both readily dissociate in a polar solvent like water, but not as easily in ethanol or isopropanol.
Therefore, the DNA pellets precipitate out of the solution when ethanol or isopropanol is added to a salty solution.