The central dogma of molecular biology: DNA makes RNA makes Protein
DNA is a reference for proteins*, which are the functional molecules in cells. These are comprised of 20 unique amino acids, and each is coded for by a stretch of DNA known as a codon. Codons are always 3 base-pairs (nucleotides) in length.
DNA is made of 4 unique nucleotides; (A)denine, (G)uanine, (C)ytosine and (T)hymine. This means that there are 64 unique codons that can be made with these 4 bases (4*4*4).
Why not just have 2-base codons?
If codons were only 2 bases in length then the variety of codons that could be created would be less (only 16 unique sequences if there are still 4 nucleotides). More unique nucleotides would be required to get enough unique sequences to code for the 20 amino acids (as well as the STOP codons). For instance, to get 64 unique sequences using a 2-bases-per-codon system there would need to be 8 unique nucleotides.
We cannot ever 'know' what happened in evolutionary terms, but it seems likely that the 3-base (nucleotide) codon system would have arisen after a period of a 2-base system, as the biological systems became more complex. This would have allowed a lot more variation in the amino-acids used, and thus more "evolvability", which would have been very advantageous to early organisms.
However as the 4-unique-nucleotide/3-codon system is ubiquitous to all life we have discovered on earth, it seems likely that, back at the start of DNA (in fact probably RNA), this was the system that worked, or at least, this is the one that survived (although as Kevin rightly points out, we don't know whether there ever were any other systems). Variations may have arisen over the years, but it is this 1 system that has prevailed here on Earth.
See this question for some more interesting info: why-20-amino-acids-instead-of-64?
*only around 1% of our genome is actually protein-coding, and many non-protein-coding RNA products have very important functions, but I won't go into this here. Suffice it to say I am referring to the protein-coding regions of the DNA.