Viruses evolve primarily through genetic mutations and recombination. Mutations can occur randomly during viral replication, leading to changes in the viral genome. Recombination happens when two different viral genomes exchange genetic material, creating new viral variants. Selective pressures from the host immune system or antiviral treatments can further drive the evolution of these variants.