The main theme of "Ode to a Nightingale" is negative capability and its power to aid the speaker in his transcendence of mortal pain and grief.
Negative capability was a term coined by Keats himself. It refers to how a poet can disregard (or negate) how they think and feel, thus being able to write entirely from their subject's perspective. For instance, in "Ode to a Nightingale," the speaker goes along with the poem's titular bird as if he is the nightingale itself. The especially vivid and striking descriptions of the forest and night in stanzas four through six exemplify how the speaker is negating himself in favor of being one with the nightingale--stanza four even starts the speaker's journey as he exclaims, "Away! away! for I will fly to thee."
However, before the speaker takes us to his feathered subject, he speaks of how harsh this world is. He proclaims that he wishes he could get drunk to forget his ills and then "with thee [the nightingale] fade away." In stanza three he goes into further detail about how awful human existence and mortal pain are:
Fade far away, dissolve, and quite forget
What thou among the leaves hast never known,
The weariness, the fever, and the fret
Here, where men sit and hear each other groan;
Where palsy shakes a few, sad, last gray hairs,
Where youth grows pale, and spectre-thin, and dies;
Where but to think is to be full of sorrow
And leaden-eyed despairs,
Where Beauty cannot keep her lustrous eyes,
Or new Love pine at them beyond to-morrow.
Yet, while the speaker is looking at the world through the Nightingale's eyes, he is content with the dark forest and sweet smells of flowers and foliage. He is able to forget mortal pain because nightingales do not know the pain of humankind. The nightingale "wast not born for death," and therefore it must not suffer through heartache, disease, and aging as humans do. The speaker feels so free of grief and detached from reality that, when the bird flays away and its song fades, the speaker must ask himself:
Was it a vision, or a waking dream?
Fled is that music—Do I wake or sleep?
Envisioning himself as a bird that was incapable of sorrow negated the speaker's personal anguish to the point where he was not sure weather his respite from agony was actually real or just a dream.
Thus, there are several themes within this poem, but escape from reality (and the associated pain of life) through the power of one's imagination is most definitely the most predominant theme.