Ordinarily each DNA molecule inside your cells contains two strands joined together by interactions called hydrogen bonds. Change in conditions, however, can "denature" the DNA and cause these strands to separate. Adding strong bases, like NaOH, dramatically increases the pH, thus decreasing the hydrogen ion concentration of the solution and denaturing double-stranded DNA.
Effects of pH
The hydroxide ion concentration and pH have a direct correlation, meaning the higher the pH, the higher the hydroxide concentration. Likewise, the lower the hydrogen ion concentration falls. At high pH, then, the solution is rich in hydroxide ions, and these negatively-charged ions can pull hydrogen ions off of molecules like the base pairs in DNA. This process disrupts the hydrogen bonding that holds the two DNA strands together, causing them to separate.
RNA vs. DNA
Unlike RNA, DNA lacks a hydroxyl group on the 2' position in each sugar group. This difference makes DNA much more stable in alkaline solution. In RNA, the hydroxyl group on the 2' position can give up a hydrogen ion to the solution at high pH, creating a highly reactive alkoxide ion that attacks the phosphate group holding two neighboring nucleotides together. DNA does not suffer from this defect and thus enjoys remarkable stability at high pH.
Molecular biologists often make use of alkaline denaturation to isolate plasmid DNA from bacteria. Plasmids are little loops of DNA separate from the bacterial chromosome. In an alkaline lysis miniprep, biologists add detergent and sodium hydroxide to bacteria suspended in solution. The detergent dissolves the bacterial cell membrane while the sodium hydroxide boosts the pH and makes the solution highly alkaline. As the broken cells release their contents, the DNA inside separates into its component strands, or denatures.
Once the biologist extracts the DNA from the cell, he adds another reagent to return the solution to a more neutral pH and precipitate the detergent. The change in pH allows the plasmid strands to reanneal; the bulky chromosome, however, cannot do the same, so the biologist can remove it together with the detergent, denatured proteins and other assorted junk, leaving the plasmid behind. Alkaline lysis does not completely purify the plasmid DNA; rather, it serves as a "quick and dirty" way to extract it from the cell and remove most other contaminants.