One thing that immediately struck me on reading the poem is how the two stanzas seem to form an argument and a counterargument. The first stanza ends with the assertion "All that we see or seem / Is but a dream within a dream", while the second ends by questioning that assertion: "Is all that we see or seem / But a dream within a dream?"
I interpret the first stanza as the narrator bidding farewell to someone as they die, someone who basically thinks the narrator is wasting his life: "Thus much let me avow — / You are not wrong, who deem / That my days have been a dream". Given the next few lines about losing hope, it seems the narrator has spent a good portion of his life being hopeless, miserable, and melancholy, on what the dying person seems to think are thin pretenses. The narrator quibbles with that:
Yet if hope has flown away
In a night, or in a day,
In a vision, or in none,
Is it therefore the less gone?
The narrator is arguing that misery is always valid, no matter the pretense, and ends by stating with a smug sort of nihilism, "All that we see or seem / Is but a dream within a dream", i.e. life is ultimately a meaningless illusion whether one spends it in misery or happiness.
However, in the second stanza, the narrator seems to begin doubting himself.
I stand amid the roar
Of a surf-tormented shore,
And I hold within my hand
Grains of the golden sand —
I interpret the "golden sand" as life, time, or opportunities to do all the things that can only be done in life: spend time with friends and family, strive to create something, fulfill passion or ambition—all the things the narrator is not taking advantage of by spending time in melancholy. The "surf-tormented shore" can represent a few things, but to me the one that feels most right is to interpret the choppy ocean as all the things that detract from spending life well: all the cruelties and obstacles that the world will throw at you to lessen the value of your life. Since the sand represents a life well spent, the waves represent something which erodes that sand away.
The next few lines also reinforce this interpretation:
How few! yet how they creep
Through my fingers to the deep,
While I weep — while I weep!
The sand is falling through the narrator's fingers into the depths of the ocean while he weeps—in other words, he is losing his chance to enjoy the good things in life while he stands at the edge of the ocean weeping. He begins asking God whether there might be anything he can do to hold on to those chances, even one of them. He ends by questioning his earlier statement: "Is all that we see or seem / But a dream within a dream?" In other words, could there possibly be more in life, even in a small way, than sitting around and moping?
While I was reading "A Dream Within a Dream", I discovered that Poe wrote another poem called "A Dream" that forms an interesting pair with it. While dreaming in "A Dream Within A Dream" represents a haze of melancholy that stops the narrator from enjoying the good things in life, the dream in "A Dream" represents a hope that carries him through the hard times:
That holy dream—that holy dream,
While all the world were chiding,
Hath cheered me as a lovely beam
A lonely spirit guiding.
In both poems, other people chide the narrator for dreaming instead of living in the present, and in both poems the narrator defies them, but in "A Dream" the narrator asserts a greater truth to be found in the dream, and chooses to dwell there as a way of preserving the goodness in his life:
What though that light, thro' storm and night,
So trembled from afar—
What could there be more purely bright
In Truth's day-star?
Whereas in "A Dream Within a Dream", the dream is meaningless and the narrator chooses to dwell there in order to wallow in self-pity.