Thank you for that good question. I am aware of at least two quality studies comparing myocarditis between the infected and vaccinated population.
One is a territory-wide study in Hong Kong (https://www.ncbi.nlm.nih.gov/pmc/articles/PMC9721305/) showing that the prognosis of Covid-related myocarditis was about 10-time more fatal than vaccine-related myocarditis.
Another is a nationwide study in the UK (https://www.ncbi.nlm.nih.gov/pmc/articles/PMC8863574/) showing that, overall, incidence of Covid-related myocarditis was still higher than vaccine-related myocarditis. But in young men who got mRNA vaccines, the reverse was seen.