How did viruses come to be?
I found a book chapter for you here

Quick summary:
3 hypotheses to Origin of viruses


From pre-cellular world (virus first hypothesis)
From reductive evolution of parasites (reduction hypothesis)
From fragments of cellular genetic material (escape hypothesis)


Drawbacks:


virus require cells (to infect) so how can they come first
virus do not look like known reduced parasites from Bacteria/Eukarya/Archaea
unlikely that genetic fragments form complex viral structures for viral function



  Because of these drawbacks, the problem of virus origin was for a
  long time considered untractable and not worth serious consideration


The rest of the chapter looks more in-depth into the 3 hypotheses