There is no biochemical constraint of any sort, so why doesn't some other code work? Why is it specifically RNA/DNA?
Any answer regarding the origins of our biochemical evolutionary origin will be reasonably speculative given that this is a very hard question to scientifically test and this field is generally understudied to say it is pretty much the most fundamental biochemical question. But there are a few reasons why RNA makes sense as the prime genetic molecule compared to other established macromolecules present in the primordial soup, and also there are good reasons why DNA superseded it as genetic storage for most cellular organisms.
In summary, the alternative abundant polymer macromolecules that came from the primordial soup aren't as versatile as RNA, and over time DNA was used more over RNA due to it being a more reliable information storage molecule.
We must remember though that the conditions that lead to the genesis of RNA is a much tougher question. There are an unfathomable amount of combinations of chemicals that could have facilitated an evolutionary process. @WYSIWYG made an excellent comment regarding why this is an almost impossible question to answer definitively:
...Why is there a phosphodiester backbone used rather than ether, amide, carboxyl ester or any other kind of linkage? Or why purines and pyrimidines, why not naphthalene ring heterocycles? Why imidazole, why not oxazole or furan? You cannot reason this out in a reverse manner.
Therefor in this answer we will be discussing RNA and other bio-polymers that were established in abundance from the very early primordial soup, not the original genesis of such biochemicals. What made each of them good vessels for an evolutionary process?
A genetic code macromolecule needs the following features:
- Variable structure.
RNA has all these and doesn't rely on a biological system for reproduction of the RNA molecule.
RNA was a good molecule because it was a polymer made of 4 base monomers that could bind with other polymers to make any array of compositions of the base components and was spontaneously replicable. This allowed a primordial form of molecular evolution as we know it today. It is able to carry more varied information than other abundant macromolecule polymers.
RNA can also carry out functions in a similar way a protein might, including catalysis. No known sugars or other macromolecules are able to demonstrate the same level of variability and versatility as RNA, although deoxyribosymes have been artificially designed in laboratories.
This probably gave it a good chance at establishing itself as the first molecule to trigger biogenesis, and this lead to nucleic acids being established as the fundamental molecule of molecular evolution.
DNA chemical structure.
Eventually RNA evolved into more complex structures and DNA broadly superseded RNA as a storage device for genetic information in cellular organisms primarily due to the increased stability DNA offers over RNA. If we take a look at DNA specifically we see a very good data storage mechanism for a couple of reasons.
- Intra-strand hydrogen bonding and different chemically structured sugar group makes a more stable overall structure.
- More rigid grooves allow proteins to bind at particular sites.
- Again, it's a polymer of variable composition.
Alternative coding macromolecules.
What are our other options from the biological polymers?
- Carbohydrates. The glycocalyx coats most cells in our body, and clearly sugars (specifically polysaccharides and glycoproteins) are an expandable, information rich molecule. However it relies on proteins for assembly in the same way proteins do, so it never really got the chance to be that prime molecule.
- Lipids. A brilliant expandable polymer, and many are spontaneously expanding in the right conditions, but generally lipids cannot carry as much "information" in the polymer (pretty much just varying lengths of CH2 groups).
- Proteins. Too complex and not spontaneously replicable. They rely on other systems for production (except in some rare examples, although they arguably still rely on a complex biological system).
That is an evidence that all the creatures share a same ancestor from evolution. About the origin of the genetic code, scientists proposed some hypotheses to explain it.
Chemical principles: From the experiments, scientists found that some amino acid have a selective affinity to certain triplet codons.
Biosynthetic expansion: The original creatures may produce amino acids as by-products of metabolism, and then some of these function into the genetic coding. Evidences show that fewer different amino acids were used in the past than today.
Natural selection: The goal of the genetic coding is to minimize the mutation. Some scientists assume that ancient life may have longer codon than triplet codon, such as quadruplet codon, but quadruplet codon have more error that triplet codon, and then only the triplet codon can survive.
- Information channel: This hypothesis suppose that the process of genetic code translation is an error-prone information channel. The organisms wanted to inherent their genetic information accurately and efficiently and stay away from the genetic noise. Genetic code should be influenced by three evolutionary force: the needs for diverse amino acids, for error tolerance and for minimal cost of resource. Finally, the genetic coding amino acids become nonrandom.
The interesting thing about evolution is that Mother Nature does not go back to the drawing board and start with a completely new design. Evolutionary changes happen in tiny increments. Faced with a problem like the appearance of oxygen in the atmosphere, evolution did not redo the whole genetic structure of plants. It tinkers. So we ended up with a wasteful and inefficient system. But it works.This kid does the most wonderful humorous video explaining this. Just google Rubisco tubes.