John Keats' poem "Endymion" is based on the Greek myth of the shepherd Endymion who spent the majority of his life in a sleep/dream state. Book I sets the stage for the story by vividly describing the things Endymion sees in his dreams.
There are a number of versions of the Greek myth that explain Endymion's perpetual sleep state and provide the basis for Keats' poem. The first is Zeus' attempt to bribe Endymion for the throne of Elis, and the second version is regarded as Zeus' punishment for betrayal. The third version explains that the moon goddess, Selene, fell in love with Endymion and put him in a perpetual sleep so that she could keep his beauty for herself.
The third version appears to be the one that Keats drew upon, and Book I serves as a summary of the lovesick prince's predicament as he attempts to make sense of his overwhelming passion and desire for the etherial Selene. At this point, Endymion is not sure whether Selene is real or simply someone he has conjured in his dreams, but he understands that "A thing of beauty is a joy forever" because "Some shape of beauty moves away the pall" of human existence and renews the spirit while it refreshes the soul.