This article is from the Douglas Adams FAQ, by Nathan Hughes nhughes@umich.edu with numerous contributions by others.
Not all of DNA's writing is easily grasped. This section includes
explanations of some of the trickier sections.
In our reality, Coleridge claimed to have composed _Kubla Khan_ in
its entirety in his sleep, and was in the process of writing it down
when a local interrupted him. When Coleridge returned to his work,
he found that he could not remember the rest of the poem. Hence,
there never was a second part of the poem. Yet, at the end of
Chapter 6 when The Director Of English Studies is reading _Kubla
Khan_ the book states `The voice (that of the director of english
studies) continues, reading the second, and altogether strange
part of the poem.'
In the book, _Kubla Khan_ has a second part. The book is not
actually set in our existence. It is set in an existence in which
the second part of _Kubla Khan_ exists. This second part of the
poem tells the ghost about the existence of the time machine and
how to travel back and stop the ship from exploding. As we well
know the explosion of the ship is what caused life to begin on
this miserable little planet of ours. When Dirk and Reg realised
this they simply went forward in time to when Coleridge was
writing the second part of _Kubla Khan_ and stopped him. Dirk just
interrupted him and talked so much that Coleridge forgot what the
second part was going to be about and therefore could not finish
it! This change of history sent reality back into our perspective
and the human race lived on (Yay, yippee!).
Quite simple really.
 
Continue to: