Nucleic acids like DNA and RNA function as informational macromolecules that store hereditary information and can produce identical copies of themselves. They are composed of nucleotides, which consist of a nitrogenous base, a pentose sugar (ribose in RNA and deoxyribose in DNA), and phosphate groups. Nucleotides bond together via phosphodiester bonds between the sugar and phosphate groups to form single strands that then interact through base pairing between complementary bases (A-T and C-G in DNA, A-U and C-G in RNA) to form the signature structures of DNA and RNA.