Occultation of planets by other planets
What you describe is a mutual planetary occultation (or transit), and yes, it has happened—in 1737—and will happen again—in 2133 (both dates are for Venus/Mercury events; there are other possible instances of planets passing in front of each other; for example, in 2065, Venus will pass in front of Jupiter). I would suggest giving a look at https://en.wikipedia.org/wiki/Planetary_transits_and_occultations
What is interesting with Mercury and Venus is that, considering the respective positions of these planets as well as the Earth, it is technically possible for Mercury to pass in front of Venus! The last time it happened was in 796, and it won’t happen again at least until the year 2500. See More Mathematical Astronomy Morsels by Jean Meeus or the link above for more information as well as for the frequency at which mutual planetary transits occur.
A “near-miss“ will happen on 27 April 2022 at 19:11 UT, when Neptune will be very close to Venus—about 25″ depending on where you will be on the Earth at that moment…