The ending stands out because it goes against the entire thrust of the rest of the book. Hank goes from triumph to triumph, turning the medieval world into an advanced society in the process. And then—in the space of three short chapters—it all falls apart. He's sent back to his own time, everything he's built falls apart, and the medieval world presumably returns to its ugly cruel ways as if he had never existed.
The last few pages cover Hank's death: in the company of a total stranger and begging for his wife who is now long gone. Sad, right? More specifically, he mentions the awful dreams he's had—presumably while he slumbered in Merlin's cave—and how he would rather die than go through them again. Merlin, it seems, really had his revenge.
Twain describes the scene from the unnamed narrator's point of view: the man watches as Hank slips into delirium. It makes sense from a practical standpoint, because why would Hank bother to write his descriptions down for us if he were dying? It also lets us see Hank from outside eyes, and take a good long look at what his separation from Arthur's land has done to him—this ups the pity factor a lot.
The ending makes the book surprisingly bitter and even a little nihilistic. At the end of the day, Hank accomplishes nothing, suggesting that mankind's idiocy and fear will ultimately triumph against his benevolence and knowledge. It's a major downer, but it also brings some poignancy to the story. Without it, Hank just wins and wins and wins… which, as anyone who's watched the New York Yankees can tell you, gets pretty boring.