Regarding immunity from infection vs immunity from vaccines, one theoretical reason to think that vaccines might be more effective at inducing immunity is that viruses have evolved measures try to hide themselves from the body's immune system while vaccines are designed to stimulate strong immune responses. Furthermore, the prime-boost strategy used by most of the vaccines might be more effective at inducing long term immunity (though we don't have a lot of data on long term immunity yet).
Empirically, an
observational study in Denmark identified 11k people infected during the first wave of COVID-19 and tracked whether they were infected during the second wave of infection. They found previous infection conferred 80.5% protection from reinfection (and a 93% protection against symptomatic infection). This level of protection is similar to that reported for the more effective vaccines (e.g. Pfizer, Moderna, Novavax). However, the study did find that previous infection was not as effective at protecting older adults (age > 65) from subsequent infection (~50% protection) whereas the vaccines above showed no signs of reduced efficacy in older individuals.
So, for younger individuals, it seems like there is a similar amount of protection from previous infection vs vaccination, but in older individuals, vaccination likely provides stronger protection than prior infection.
On the issue of the evolution of variants in vaccinated populations, one leading hypothesis on the evolution of the variants is that arise during long term infection of immunocompromised individuals (see my
previous post for more discussion and citations to the scientific literature). This idea fits with general thinking about natural selection. It has been observed (for example, in
studies of the evolution of antibiotic resistance in bacteria), that low levels of selection give the best chance for new traits to evolve. If there is no selection, there is no pressure for new variants to take over the population. Similarly, high levels of selection are problematic for the evolution of new traits because 1) if selection is too strong, the organism just dies off before resistant variants are able to arise and 2) mutations that might provide new traits (e.g. antibody resistance) usually also compromise the function of the protein, so these neofunctionalizing mutations often need compensatory mutations to come along to restore the function of the protein. High levels of selection impose a high cost to these neofunctionalizing mutations, which stops them from accumulating in the population.
Long term infection of an immunocompromised host would provide a perfect environment where the virus is exposed to selection by the human immune system, but that selection is too weak to eliminate the virus. This gives the virus the opportunity to accumulate mutations until eventually a set of mutations arise that allow it to get around the immune system and replicate more quickly than the original virus.
Under this hypothesis, the greater number of people infected, the greater the chance that the virus might find such a suitable host where this type of evolution can occur. Increasing the population of vaccinated individuals would decrease the number of vulnerable individuals and limit the spread of the virus, lowering the number of people carrying the virus, lowering the probability that the virus could evolve new variants. Having fully vaccinated people in the population would present the "strong selection" case discussed above, which would likely present challenges to the evolution of new variants.
Consistent with this idea,
preliminary data from Public Health England suggests that the Pfizer vaccine seems to protect against new variants such as alpha (B.1.1.7) and delta (B.1.617.2). It's likely that these variants spread throughout the world primarily because of their increased transmissibility, not their ability to get around pre-existing immunity.