The evolutionary origins of viruses is disputed. Although they don't leave a fossil record it's known that they are ancient (at around 4.5 billion years old).
It's not known, however, whether they evolved from cellular lifeforms, or pre-dated them.
There are three classical hypotheses on the origins of viruses: • Viruses may have once been small cells that parasitised larger cells (the degeneracy hypothesis, or reduction hypothesis);
• Some viruses may have evolved from bits of DNA or RNA that "escaped" from the genes of a larger organism (the vagrancy hypothesis, or escape hypothesis);
• Viruses could have evolved from complex molecules of protein and nucleic acid before cells first appeared on earth (the virus-first hypothesis). None of these hypotheses have ever been fully accepted."
Source : Wikipedia
Note: Another theory is that viruses may have evolved away from Earth, arriving here from deep space. The Panspermia theory - the roots of which go back at least as far as the 5th century BCE - was popularized in the 1980s by Fred ('big bang'plugin-autotooltip__plain plugin-autotooltip_bigBig Bang theory
There is now a large body of evidence (from different sources) to support the Big Bang Theory for the origin of the universe, but the problem remains as to the origin of the material or energy which initialised it.
As the UK’s Astronomer Royal Martin Rees has put it :) Hoyle and Chandra Wickramasingh. Although there is now a growing body of evidence appearing to support the theory - or at least not contradict it - it's still not widely accepted by experts in the field.
Further reading Advances in Genetics, Volume 106, pp.101-107
Importance Rating