Many viruses, particularly RNA viruses, mutate at a very high rate per genome per replication. One possible explanation is that high mutation rates are selected to meet the challenge of fluctuating environments, including the host immune response. Alternatively, recent studies argue that viruses evolve under a trade-off between replication speed and fidelity such that fast replication is selected, and, along with it, high mutation rates. Here, in addition to these factors, we consider the role of viral lifehistory properties: namely, the within-host dynamics of viruses resulting from their interaction with the host. We develop mathematical models incorporating factors occurring within and between hosts, including deleterious and advantageous mutations, host death owing to virulence and clearance of viruses by the host. Beneficial mutations confer both a within-host and a transmission advantage. First, we find that advantageous mutations have only a weak effect on the optimal genomic mutation rate. Second, viral life-history properties have a large effect on the mutation rate. Third, when the speed-fidelity trade-off is included, there can be two locally optimal mutation rates. Our analysis provides a way to consider how life-history properties combine with biochemical trade-offs to shape mutation rates.