DNA is a more stable molecule that evolved from RNA.
RNA has great capability as a genetic molecule; it once had to carry on hereditary processes on its own. It now seems certain that RNA was the first molecule of heredity, so it evolved all the essential methods for storing and expressing genetic information before DNA came onto the scene. However, single-stranded RNA is rather unstable and is easily damaged by enzymes. By essentially doubling the existing RNA molecule, and using deoxyribose sugar instead of ribose, DNA evolved as a much more stable form to pass genetic information with accuracy.
Experiments in the 1960s showed that messenger RNA has the ability to store genetic information, while transfer and ribosomal RNA have the ability to translate genetic information into proteins. Experiments performed two decades later showed that some RNAs can even act as an enzyme to self-edit their own genetic code! These results raised two questions: 1) Why does RNA play so many roles in the flow of genetic information? 2) Why bother storing genetic information in DNA, if RNA alone could do the job?