A virus is the stuff of mystery and fear, an invisibly lurking danger ready to spread explosively around the globe. The new coronavirus, like SARS, MERS and the seasonal flu, enters our bodies, finds its way inside our DNA and commandeers it to make more copies of itself. Viruses are, in many ways, the ultimate parasites.

Yet we, like every other creature on Earth, have a complex relationship with them. Many of the traits that make viruses so effective at transmitting disease also make them an essential part of our genetic...