|MadSci Network: Astronomy|
Let's see, what would it feel like on Earth if there was a "near miss" by another planet? First of all, there might be lots of panic and fear and running around, it would certainly be a scary sight seeing a huge object whoosh overhead ... but what physical forces would be involved?
If the planets are not colliding, then the only physical force involved is gravity. And, actually, we're already familiar with what would happen if a large planet passed close by Earth ... The Moon is doing it all the time! And the Moon, aside from providing light and being an interesting place to visit, has only one immediate effect on earth: tides. So if another planet were to swing by, its main gravitational effect would be tidal forces. Tides occur because the moon's gravitational force is stronger when it's nearby (i.e. overhead) than when it's far away (when it's on the other side of the Earth). A good way to think about tides is to imagine that any object wants to "stretch out" towards a source of gravitational force. The Earth by itself wants to be a sphere, but when the moon is pulling on it, it'd rather be a football. The Earth's oceans, atmosphere, and even its crust have to "rearrange" themselves somewhat to become more football-shaped in the direction of the Moon. That's what causes water tides (a few meters high), air tides (imperceptible from the ground, I think) and land tides (which are measureable!) Try searching the Mad Scientist archives for more about tides.
Yeah, but these tides come and go without destroying the planet. If Mars were to swing by the Earth, it would cause tides of exactly this sort ... which would subside without destroying the planet. They can be bigger or smaller tides, depending on how close the two planets get, but it's always the same general effect.
If two planets were to pass really, really close to one another, the atmospheres could get messed up. There's a concept in astronomy called "Roche lobes" which we apply to binary star systems. In a nutshell, if two stars are close enough together, one star's outer atmosphere can fall onto the other star. The details are explained in another MadSci answer. But the same idea works for planets: if Mercury and Mars pass by one another, close enough that Mars' atmosphere fills its Roche lobe, then Mercury can collect some of Mars' gas. Thinking about the tidal football I mentioned before, imagine that the originally-round planet streches so much that the tip of the football reaches the moon.
However, this involves the planets passing really, really close - probably a few hundred kilometers away from an actual grazing collision. Tidal forces in the land might now be strong enough to cause earthquakes, upheavals, etc. Also, two planets swinging by each other at a distance of a few hundred kilometers have to be going really fast; they'd probably be really close to one another for something like an hour or two. At these speeds, it's not clear that there's enough time to transfer a lot of gas over. It's possible to calculate all of these numbers using classical mechanics.
So in the end, I think that a very near miss between two planets would cause destructive tides and upheavals and only perhaps could steal a significant amount of the atmosphere. It's a very complicated system, though, and only a lot of analysis (or a good computer simulation!) can tell us all of the details. I've seen fascinating simulations of a moon-sized object crashing into the Earth ... I've never seen a simulation of a very near miss.
I should add that, the way we understand things now, the planets have never done a lot of meandering around the Solar System; Mercury probably formed from dust and rubble that was already in or near that orbit; Mars probably formed from dust and whatnot near its own orbit. And both planets have probably been in the same neighborhood for their whole lives ... so Mercury has never been anywhere near Mars. However, we're a long way from understanding the details of the formation of the Solar System (and this isn't my field of expertise) so new theories are certainly welcome! Check out The Nine Planets, in the MadSci library, to learn more.
Also, it's entirely possible that Mars lost its atmosphere on its own. Until someone figures out how to put a plastic bubble around the whole thing, the only thing holding Earth's amosphere down is gravity. Gravitational force around here is pretty strong, but it can't do everything: for example, while Earth's gravitational force is strong enough to hold onto nitrogen and oxygen, it's not strong enough to hold hydrogen and helium! Knowing the strength of the gravitational field and the temperature of the upper atmosphere, it turns out that a helium atom is just as happy escaping into space as staying on Earth. It just boils away. On Mars, just like on the Moon, perhaps gravity isn't strong enough to hold much of anything; if Mars once had a thick atmosphere, it may have just boiled off into space over millions of years. The history of Mars' climate, geophysics, and atmosphere is the subject of intense study, and today there isn't a definitive understanding.
Thanks for an interesting question!
Try the links in the MadSci Library for more information on Astronomy.