The albums you should buy depends on the U2 era you like. 80s, 90s, and 2000s U2 are completely different.
The 80s U2

I think someone can buy The Joshua Tree and The Best of 1980-1990 and have the essential U2 stuff of the 80s. The Joshua Tree is almost a "Best of" within itself, but with The Best of 1980-1990, the listener gets the essential songs from other albums as well, such as "Sunday, Bloody Sunday", "Pride", and "Desire".
1990s - Present

While no lesser in quality, the last 2 decades have produced 5 studio albums, compared to 6 in the 80s. I would recommend:
Achtung Baby - includes "One" and "Mysterious Ways"
All That You Can't Leave Behind - "Beautiful Day" and "Elevation"
How to Dismantle an Atomic Bomb - "Vertigo" and "City of Blinding Lights".
These are, in my opinion, the 5 essential albums. All are good, but you will get the essential U2 with these 5. One notable exception is the Pop album, which people either love or hate.
If you have a little more time/money, I would recommend:

War - Political, and at the same time, not that political. But a fierce album.
The Unforgettable Fire - This album isn't full of your typical songs, but more like soundscapes. "Pride" is the only song that has the typical verse-chorus-verse-chorus structure.
Zooropa - Just an all around weird and great album.
Update: Josh pointed out a major oversight. I forgot about the U218 singles album. If you want just one album that spans U2's career, then get this album. It looks like it has all the essential songs, especially from the 5 albums I mentioned.

So, if you want 1 album, get the U218 singles. If you want to explore them a little more, I recommend the 5 previously mentioned.
