Much of the structure and function of nucleic acids revolves around the concept of base complementarity. DNA and RNA molecules are not able to bind at random with one another, or even flexibly, as in the case of protein interactions, rather a specific set of patterns called based complementary governs how nucleic acids behave.
The five nucleobases, adenine, cytosine, guanine, thymine and uracil contain nitrogen and oxygen atoms, as well as carbon and hydrogen atoms. These nitrogen and oxygen atoms lead to specific parts of the molecules having certain charges, which wouldn't be the case in purely carbon and hydrogen containing molecules. These specific charges mean that there is the presence of opposite charges between specific molecules. This is base complementarity.
The guanine and cytosine molecules are each able to form three intermolecular interactions between each other. Meanwhile adenine and thymine (or uracil) are only able to form two interactions (Figure 1). These interactions are specific, and only occur between one of each of these molecules, due to the specific charge patterns each molecule contains.
This base complementary, through opposite charge attraction, is the basis behind much nucleic acid chemistry. Base complementary dictates how DNA is transcribed into mRNA, as nucleotides will be incorporated into the mRNA in accordance with base complementary to the template DNA. Similar the process of protein translation involves mRNA binding in a complementary manner to tRNA. DNA replication, whether in vivo, or in processes such as polymerase chain reaction, similarly involves nucleotides being incorporated into the new DNA molecule on the basis of base complementary.
Occasionally base complementary can fail and nucleic acids can be misincorporated. When this happens, which it can do occasionally, it gives rise to genetic variants, which depending on the organism, may be corrected by proofreading enzymes. Although some organisms such as HIV do not have any proofreading activity, and seek to maximize the amount of genetic variance they have as part of their evolutionary strategy.