Overcoming viral infection offers inoculation. A host learns about the virus, which invariably leaves genetic material behind. By being able to spot an intruder early, this recognition memory is weaponry against reinfection.
A virus generally kills its host cell, but some cells escape destruction by harboring the virus, Trojan-horse style. Such persistent infections can last from a few weeks to years. The measles virus can remain hidden in brain cells for years, eventuating into progressive damage and disease.
Oncogenic viruses enter host cells and permanently change its genome (transformation), leading to cancer. Transformed cells take on a whole new life, which basically translates to becoming a different cellular beast and going on a rampage: chromosomal alterations, changes in cell surface molecules, increased growth rate, and the ability to divide for indefinite durations. Mammalian viruses capable of initiating tumors are termed oncoviruses.
Less malevolent viruses move in and take up residence, lasting the host’s lifetime without significantly degrading quality of life. Having learned accommodation in evolutionary time, these viruses are typically content with quiet title. Herpes is exemplary.