The prevailing idea among molecular biologists is that RNA came first, in an "RNA world".
There are several arguments used to support this idea. One is that DNA needs RNA in order to replicate, but RNA can replicate itself. Also RNA has catalytic properties; DNA does not. The first nucleic acid must have been able to replicate itself and to catalyze the process.
Another line of evidence involves the way that most cells synthesize the components of the two nucleic acids. The nucleotides of RNA (ribonucleotides) are assembled from simpler molecules, but those of DNA are produced by modification of ribonucleotides (the sugar of the ribonucleotide, ribose, is reduced to form deoxyribose, and if the base in the nucleotide is uracil it is methylated to form thymine).