John Keats, who is famous for writing “Ode on a Grecian Urn,” died in 1821. Apparently he wrote the sonnet when he was waiting for a boat to Italy with his friend Percy Shelley in the autumn of 1820.
The journey was difficult, and Keats was dying. He was exhausted when they reached their destination, but the beauty of it inspired him.
The change in him was wonderful, and continued even after our return to the ship, when... he wrote me the subjoined sonnet, which, at the time I thought the most enchanting of all his efforts. (http://www.guardian.co.uk)
Shelley, a poet himself, was inspired by the poem. It is a simple but beautiful piece. It is clearly Keats’ image of his own mortality.
To feel for ever its soft fall and swell,
Awake for ever in a sweet unrest,
Still, still to hear her tender-taken breath
And so live ever - or else swoon to death. (http://www.guardian.co.uk)
Sadly, it was the last sonnet he would ever write. It seems that Keats was inspired by his friend and by Shakespeare to write a sonnet instead of an ode. He wrote the poem inside a volume of Shakespeare’s sonnets for his friend. According to Percy, Keats went to Italy to die.