Well, DNA specifically seems to have evolved. If you look at a modern cell, the only thing that DNA actually does is long-term storage of genetic material. The actual "heavy lifting" is done by transcribing DNA into RNA, which then does actual stuff.
But, I guess, what you are actually asking is, where did these kinds of molecules originally came from? The short answer is, they form naturally under conditions that were somewhat common on early earth.
On modern earth, this no longer happens, because life completely changed the composition of earth's atmosphere. Mainly, it exhausted nearly all CO2 and methane and replaced them with O2, which is extremely hostile to organic compounds.
In an atmosphere rich in CO2, methane, nitrogen and ammonium (as it was on early earth), organic compounds form rather easily on their own. This can happen in wide variety of ways, so you're unlikely to find a definitive answer, for which process specifically created what on early earth.
If you look at the basic compounds that make life (sugars, nucleotides, lipids, aminoacids), they all share one key property - they are somewhat soluble in water. This means, that they can accumulate in solution as they get formed. The other junk that is insoluble either sinks or floats to the top.
Lipids also have a curious property - once they reach high-enough concentration, they start forming micelles, membranes and vesicles.
Sugars, nucleotides and amino acids have another property - they can form polymers (polysacharides, nucleic acids and preptides, respectively), that can't penetrate lipid membranes as easily as their respective monomers. They can get trapped in vesicles and therefore can accumulate over time.