Viruses evolve in infected host populations, and host population dynamics affect viral evolution. RNA viruses with a short duration of infection and a high peak viral load, such as SARS-CoV-2, are maintained in human populations. By contrast, RNA viruses characterized by a long infection duration and a low peak viral load (e.g., borna disease virus) can be maintained in nonhuman populations, and the process of the evolution of persistent viruses has rarely been explored. Here, using a multi-level modeling approach including both individual-level virus infection dynamics and population-scale transmission, we consider virus evolution based on the host environment, specifically, the effect of the contact history of infected hosts. We found that, with a highly dense contact history, viruses with a high virus production rate but low accuracy are likely to be optimal, resulting in a short infectious period with a high peak viral load. In contrast, with a low-density contact history, viral evolution is toward low virus production but high accuracy, resulting in long infection durations with low peak viral load. Our study sheds light on the origin of persistent viruses and why acute viral infections but not persistent virus infection tends to prevail in human society.