In the 1970s and early 80s, when someone talked about their campaign, they'd say, "In my dungeon..." It wasn't until later on that people would say, "In my world..." At some point, D&D left the dungeon, and became about worldbuilding.*
Is it possible to go back? Of course. Products like Ruins of Undermountain, Return to the Temple of Elemental Evil, World's Largest Dungeon, and Castle Whiterock prove that it's possible to create a single campaign that takes place entirely or mostly in one large underground complex.
Perhaps a better question would be, should we go back? Should we try to create a whole campaign around a dungeon? Or rather, a megadungeon? Here's why the answer might be yes:
So then, how do you do it? How do run a dungeon as a campaign without the players getting bored?
Well, first of all, you expand your horizons about what the definition of a megadungeon is. You incorporate all the changes in environment and play experiences mentioned in point 4, above, and more. The actual rooms-and-corridors standard concept of the dungeon isn't the entire campaign, it's just the focal point of it. The campaign itself also involves the area around the dungeon, places the dungeon links to (physically, like an old ruin on the surface or the Underdark, and magically, like other distant locations or other planes), and nearby urban areas that the PCs must travel to. In other words, the dungeon campaign is going to involve a lot of adventures in locations other than traditional underground rooms and corridors.
Second, you make those rooms and corridors as interesting as possible. Worry less about "realism" and more about fun. (I'll be writing here in future entries about the difference between realism and believability. In short, however, chasing after the former can lead you astray if you're not careful, but the latter can go nicely hand in hand with excitement and fun.) Use the dungeon as a magical place to stage thrilling encounters with strange conditions--collapsing floors, rivers of lava, areas without gravity, and so on. Use the alien underground environment to place strange creatures, treasures, and obstacles that you would never find on the surface. And make use of the alienation and feeling of displacement the player characters (and the players) feel when they are deep, deep within the dungeon to create nail-biting tension and awe-inspiring wonder.
Lastly, you make the dungeon a dynamic place that is always changing, both because of PC actions and NPC actions. You make the dungeon so big that it's an environment, not a single locale. The PCs can no more clear it out and "finish" it than they can clear out an entire desert or mountain range and finish that.
When running a dungeon campaign, give the player characters an opportunity to leave the dungeon to rest, recuperate, and re-equip. Create adventures that link to events and creatures in the dungeon that take place outside of the dungeon. The nest of dopplegangers the PCs stirred up come after them in the nearby town, for example. The curse associated with the artifact they bring to the surface alters the surrounding land. The evil temple the PCs raided in the dungeon sends demons to attack them while they rest in the lands above.
Likewise, events on the surface affect the dungeon. War ravages the surrounding lands, making travel to and from the dungeon more difficult. New adventurers come from a distant land to raid the dungeon for treasure even as the PCs continue their explorations. NPCs, hearing about the PCs' successes in the dungeon, arrive to commission them to find an entirely new treasure or complete some other quest within the labyrinths below.
It all comes down to keeping thing dynamic, keeping things interesting, and changing things around from time to time. Which really are perhaps three of the main tactics for running any good campaign, dungeon or no.
*Of course, I'm generalizing here. Plenty of DMs (including myself) before then were worldbuilding, and plenty were running virtually nothing but dungeons after that point.