Does someone know why DNA is composed of four nucleobases? In particular, is there an explanation for the number? Why four and not two, or eight?
A now deleted answer put this down to an argument based on amino-acid coding in codons but, as pointed out by Konrad Rudolph in a comment, arguments based on codons cannot be correct because the 4-base system likely pre-dates the evolution of protein translation.
So why four?
I suggest that it comes from a combination of factors which make it a 'just right' fit for RNA-based replicators: more would be bad, and less would also be bad. The four bases are able to copy with high reliability because two features combine to exclude mis-pairings: there are two size classes - meaning any purine-purine or pyrimidine-pyrimidine pairing results in incorrect separation between the strands, excluding A-G and C-U bonds; and there are two classes based on number of OH-bonds - which limits the potential for A-C and G-U bonds. More bases must, inevitably, weaken the strength of these exclusionary approaches and increase the number of mispairings. RNA world replicators will have lacked the sophisticated repair and error checking mechanisms of modern lifeforms so this increase in mispairings would likely not be corrected.
Of course, a two base system would be even more capable of reducing errors. I suggest that the advantage of the four base system is that it allows for much more complex 3-dimensional structure to form in RNA and thus enabled a broader range of catalytic capabilities. I've only considered even-numbers because only even numbered systems could use the Watson-Crick style of base pairing.
I'd also suggesting reading Eörs Szathmáry's 2003 paper on this very question.
A group in California has just published a paper in which they successfully added a third base pair stably into DNA. I think this could shed some light on why four - you can read about it here or get the full paper here (Nature, so pay walled).
There is a chemical dimension to this question too.
If you look at the Watson-Crick Base pairs you can see that there isn't a lot of wiggle room:
The nucleotide bases have 2 or 3 hydrogen bonds. It's probably not sterically reasonable to have 4.
That means there are only a limited number of ways the base combinations can be complimentary and also specific as they form the double helix. Since A->T and T->A hydrogen bond patterns take up both donor-receptor combinations there is one possible 2 H-bond pairing.
There are 2 ways to configure the three hydrogen bond bases I think, so perhaps six is possible, but I'm guessing that if you expand the base pairing repetoire, one could start to lose specificity. As it is, if you play with nucleotides enough, you can make non Watson-Crick base pairs and probably lose some of the confidence you have exact 1:1 matches between complimentary base pairings. Wobble Base pairs in RNA and Hoogsteen Base Pairings can already be demonstrated to allow triple helixes and non-perfect match RNA helices.
Here is a possible answer given by this paper:
It gives a Darwinian explanation to the question. It approaches the problem from Claude Shannon's theory for communication. It treats DNA replication conceptually and mathematically the same as a data transmission. It concludes that the system of four bases, not two, not six, replicates the most genetic information at the shortest amount of time.
The communicational analogy goes like this. If you have two data transmission systems, one can transmit, say, 1 MB per second, and the other can do 2 MB per second but cost less than twice as much. The answer is obvious you will buy the second service for a higher rate per cost. As a data service, it does not care what information you consume -- it can be spam, video, audio, etc. All that matters is the transmission rate. As for DNA replication, it is like a data transmission channel when one base is replicated a time along the mother DNA template. It too does not care whether the process is for a bacterium genome, or a plant, or an animal genome. The pay-off is in information and the cost is in time. Unlike your abiotic communication varieties, time is both the sender and the receiver of all messages of life, and different life forms or species are merely time's cell phones. So if one system can replicate more information in a unit time than another, the faster one will win the evolutionary arm race. A prey operating on a slow replicator system will not be able to compete with nor to adapt to a predator operating on a fast one.
Now because the A-T pair has only two weak hydrogen bonds but the C-G pair has three, A and T take a shorter time to complete duplication than the C and G do. Although the replication time is short in some fraction of nano second, but the time adds up quickly for genomes with base pairs in the billions. So having the C-G pair may slow down the replication, but the gain is in information. One base pair gives you 1 bit per base information. Two pairs gives you 2 bits per base information. But, having more base pairs may eventually run into a diminished return in information replication rate if the new bases take too long a time to replicate. Hence the consideration for the optimal rate of replication measured in information bits per base per time. Without information there would be no diversity, no complexity. Without replication in information there would be no life.
Using a simple transmission/replication rate calculation by Shannon you can calculate the mean rate for the AT-system, the CG-system, the ATCG-system, and for some hypothetical 6-bases, 2n-bases system whose new bases take progressively longer time to replicate. The analysis shows the ATCG-system has the optimal replication rate if the CG bases take 1.65 to 3 times longer to replicate than the AT bases. That is, a base-2 system replicates its bases faster but does not carry more information to have a higher bit rate. Likewise, a base-6 system has a greater per-base information but replicate slower on average to end up with a suboptimal bit rate.
According to a comparison from the paper, the base-4 system is about 40% faster than the A–T only system, and 133% faster than the G–C only system. Assume life on Earth started about 4 billion years ago, then the A-T only system would set back evolution by 1 billion years, the G–C system would do so by 2.3 billion years. For a hypothetical base-6 system, it would do so by 80 million years. In other words, life is where it should be because the base-4 system is able to transmit information through the time bottleneck at the optimal bit rate.
In conclusion, life is to replicate the most information with the shortest time, and the base-4 system does it the best. If ever there were other systems they would have lost the informatic competition to the base-4 system from the get-go. Darwin's principle works at life's most basic and most important level.
There are other explanations, all non-Darwinian. Most are based on the base's molecular structures. But these types of explanation border on circular argument -- using observations to explain themselves. They also face this catch-22 problem since there is no way to exhaust all possible bases for replication. However, such lines of exploration are fruitful regardless because more knowledge the better. But without taking information and its replication into consideration it is hard to imagine a sensible answer to the question.
The 4-bases DNA system with A-T bonds and C-G bonds is the one that evolved to be used by most living creatures on Earth, as mentioned in other answers, because it can encode a triplet table of bases for all aminoacids used, allowing for some aminoacids to have more than one triplet code. There are though slight variations of the system: even though the A-T and C-G bonds don't change, the nucleotides can be modified to mark areas of the genome in what is part of the epigenetic code. The most common modification is adding methyl and 5-hydroxymethyl molecules to the bases, although more modifications are still being discovered.