The origin of molecular machines
The main hypothesis is that all starts from RNA. "The RNA world". There was no DNA and no proteins. Both function was performed by RNA. Now there are no living organism that carrying information in RNA (only viruses...), but there is "enzymes" from RNA - ribozymes. 
The evolution to DNA was later, according to this hypothesis.
There is really good article in wiki. 
http://en.wikipedia.org/wiki/RNA_world_hypothesis
or if you want something more look here
http://www.ncbi.nlm.nih.gov/books/NBK26876/

Summary


  From our knowledge of present-day organisms and the molecules they contain, it seems likely that the development of the directly autocatalytic mechanisms fundamental to living systems began with the evolution of families of molecules that could catalyze their own replication. With time, a family of cooperating RNA catalysts probably developed the ability to direct synthesis of polypeptides. DNA is likely to have been a late addition: as the accumulation of additional protein catalysts allowed more efficient and complex cells to evolve, the DNA double helix replaced RNA as a more stable molecule for storing the increased amounts of genetic information required by such cells.