The similarity in the DNA of two species is the best evidence to tell us how closely related the two species are. Another significant source of evidence is the similarities in the amino acid sequence of the proteins of the two species. Thus, scientists can look for similarities in the DNA and amino acid sequence to determine how closely related the two species are.
The characteristics of an organism are determined by its genes, which are nothing but specific sequences of DNA molecules. Genes also determine the type of protein produced in an organism and hence amino acid sequence in proteins is also a function of DNA. It is a rather routine laboratory exercise for scientists to determine these two characteristics for any given organism. The similarities in DNA and amino acid sequence is known to be directly correlated to evolutionary relationships between species.
It should also be noted that genetic variation is a key to evolution. If genes are similar (or the same), evolution does not take place and offspring are similar to the parents. Thus, similar species will have similar DNA.
Some other factors that scientists use to determine the similarity between species are body structures, patterns of early development, and the fossil record.
Hope this helps.