Before DNA can be sequenced, tested or analyzed, it must first be extracted from cells. Cells contain many other molecules like proteins and lipids; however, and a scientist naturally wants to get a solution of DNA that's as pure as possible. Common methods of DNA extraction involve the use of isopropanol or ethanol in one step of the process.
Both ethanol and isopropanol mix well (are miscible with) water, but they have lower dielectric constants than water, meaning that their ability to shield positive and negative charges in the solution and keep them segregated is much poorer. The dielectric constant for water, for example, is 78.5, while the constant for ethanol is 24.3. DNA is negatively charged, so it's attracted to positive ions in the solution like potassium or sodium. Ethanol has a poorer ability than water to keep the positively charged ions and the DNA apart.
Ethanol also makes the DNA less soluble for another reason. Since the ethanol molecules can form interactions called hydrogen bonds with water molecules, they decrease the number of water molecules available to hydrate the DNA. Between this effect and the lower dielectric constant, the ethanol basically causes the DNA to aggregate with positive ions in the solution, forming a solid or precipitate at the bottom of the tube. Precipitating the DNA serves to make it more concentrated because other contaminants in the solution are not precipitated at the same time.
The ethanol wash also serves to remove low-molecular weight contaminants like salts and detergents. The salt chosen may vary depending on whether it's necessary to precipitate the sodium dodecyl sulfate detergent from an earlier step; potassium dodecyl sulfate, for example, is insoluble and will precipitate, so using potassium acetate in an alkaline lysis can remove the SDS before the ethanol/isopropanol is added. Ethanol can also be used to precipitate RNA for much the same reasons, although precipitation of RNA will typically require more ethanol.