For most immunities, vaccines not only are safer but produce a more robust response. This includes vaccines for HPV, tetanus, and pneumonia; mumps is an exception. The other benefit of a vaccine over natural immunity is its standardization. First, unlike acquiring natural immunity, you can choose when you get vaccinated. Second, while natural immunity provokes a range of responses, vaccines are designed to create the most significant immune response without safety concerns.
For the COVID-19 vaccines, there remain two questions. How long will the immunity last? We don’t know yet, but only time will tell. Again, most vaccines confer equally long-lasting immunity. The two mRNA vaccines are targeted at the spike protein. Natural immunity can target the spike and other viral shapes, which might allow natural immunity to protect against some variants; again, we do not know. What we do know is that getting your immunity by contracting COVID-19 is a crapshoot; being vaccinated is exceedingly efficacious and safe.