Summary:
The Restaurant at the End of the Universe begins just as The Hitchhiker's Guide to the Galaxy ended. Arthur Dent, Ford Prefect, Trillian, and Zaphod Beeblebrox have just left the planet Magrathea when they are attacked by a Vogon ship. They find they are unable to use the Improbability drive to escape, as Arthur has accidentally jammed the computer with a simple request for a cup of tea which proved a rather difficult problem. Luckily, an ancestor of Zaphod's, Zaphod Beeblebrox the Fourth, saves them.
Zaphod and Marvin vanish, and reappear at the offices of The Hitchhiker's Guide to the Galaxy editorial building on Ursa Minor Beta. They are looking for Zarniwoop, who has gone on an intergalactic cruise in his office via his virtual universe. Arthur, Trillian and Ford are unaware of any of this, knowing only that the computer has been shut down, and only having received a message from a stalling Nutrimatic that says "Wait."
When Zaphod and Marvin reach the fifteenth floor of the Guide's office, half of the building is lifted off the ground by Frogstar Fighters. A mysterious man named Roosta brings Zaphod to Zarniwoop's office, where they wait until the building lands on Frogstar World B. Roosta gives Zaphod final instructions before he leaves: Go through the window on his way out, not the door. Zaphod then meets Gargravarr who informs Zaphod that he is to be sent through the Total Perspective Vortex, a torture device which annihilates you by showing you just how infinitely small you are compared to the Universe. However, when Zaphod enters it, the Vortex shows him that he is the most important thing in the Universe. Zaphod escapes, and finds Zarniwoop in the first cla** cabin of a spaceliner in an abandoned spaceport.
Zarniwoop explains that the total Perspective Vortex has not malfunctioned — this is a virtual universe created by Zarniwoop for the sole benefit of Zaphod, who is the most important creature in this universe. It turns out that Zaphod had the shrunk Heart of Gold in his jacket pocket the whole time. It is reconstituted, and Zaphod is reunited with Trillian, Arthur and Ford. They escape from Zarniwoop by asking to be transported to the nearest restaurant. Milliways, the Restaurant at the End of the Universe, is the nearest restaurant in space but not time. They are transported there "five hundred and seventy-six thousand million years" into the future. Marvin is left stranded here for this incredibly vast amount of time parking diners' spaceships while waiting for the humans to return. After the meal, Zaphod and Ford steal a spaceship, which turns out to be a stuntship belonging to the rock band Disaster Area, programmed to dive into a star to provide backing effects for a rock concert. There is a teleporter on the ship for which the guidance system was never built, as it was never intended to be used, and it also requires somebody to stay on the ship to operate it. Marvin is chosen to stay behind and teleport the others, who have no choice but to go wherever it takes them.
Zaphod and Trillian are returned to the Heart of Gold, which is commandeered by Zarniwoop to complete his mission, to discover who really rules the Universe. As it turns out, the Ruler of the Universe is entirely sceptical that he holds this position, as he is entirely sceptical of everything, including whether his cat, The Lord, really exists, or whether there is even a universe at all outside of his small isolated home. While Zarniwoop attempts to impress upon the Ruler of the Universe the reality and the weight of his position, Trillian and Zaphod sneak out and fly the Heart of Gold away.
The teleporter has meanwhile sent Arthur and Ford to the Golgafrinchan Ark Fleet Ship B, a ship of fools which crash-lands on prehistoric Earth. They realise that the bumbling travellers are the real ancestors of modern humans. Arthur attempts to determine the Question to the Ultimate Answer of Life, the Universe and Everything by reaching into a Scrabble bag made from Ford's towel and pulling out letters randomly, hoping Deep Thought's computational matrix in Earth would have rubbed off on his subconscious. The letters spell "What do you get when you multiply six by nine"[2] before running out, although the Neanderthals manage to spell "forty-two" with the tiles, implying that it is they, rather than the Golgafrinchans, who were intended to be part of Earth's computer matrix. After some brief contemplation, Ford and Arthur realise that this is, in fact, a detrimental "co*k-up," and that the Earth will never produce the proper Question, thus destroying all hope of ever finding out what it is.
As Ford convinces Arthur that there is nothing that can be done to improve the inevitable history of the Earth, Arthur decides that he should make the best of his situation and settles for a life on prehistoric Earth.