His primary explanation of the word is given in his essay "On Fairy-Stories":
But the 'consolation' of fairy-tales has another aspect than the imaginative satisfaction of ancient desires. Far more important is the Consolation of the Happy Ending. Almost I would venture to assert that all complete fairy-stories must have it. At least I would say that Tragedy is the true form of Drama, its highest function; but the opposite is true of Fairy-story. Since we do not appear to possess a word that expresses this opposite — I will call it Eucatastrophe. The eucatastrophic tale is the true form of fairy-tale, and its highest function.
Eu (ευ-) is a common Greek term meaning "good." Catastrophe is an English word meaning "sudden and unexpected disaster", from Greek καταστροφή, 'destruction'. And so eucatastrophe is a noun referring to "a sudden and unexpected good or happy ending", as the antonym to catastrophe.
The idea of a sudden and unexpected "happy ending" coming out of bad was drawn from Tolkien's Catholic faith, for he called the Incarnation of Christ the eucatastrophe of "human history" and Christ's resurrection the "eucatastrophe of the Incarnation."
The design of "Eucatastrophe" is found twice in The Return of the King: It first occurs when Aragorn, who had been thought not to return from the Paths of the Dead, suddenly appeared with the Grey Company out of the Black Ships, at the very moment the Corsairs were instead expected to arrive and complete Mordor's defeat of Minas Tirith. This turns the tide of the battle, and the Enemy's hope is lost. It happens again when the One Ring is at last destroyed by Gollum at the Crack of Doom, in spite of Frodo's failure to relinquish it, which brought a sudden end to all evil.