afaiu, in theory, immunity acquired through infection can be stronger than the one from vaccination. E.g. vaccination might prime your body for just one protein, whereas an infection would prime for several.
But it's not universally true, varies for different viruses, and also isn't fully understood whether it's the case for covid. So far seems like a safer and less miserable opinion to get vaccinated rather than get sick with covid.
In certain cases it may be that getting a mild infection does help prevent later more serious infections, but AFAIK those cases are generally getting infected as an infant or child. I’m not aware of evidence showing that current widespread vaccines for adults have this effect of trading mild illness now for more serious illness later.