A nanobot is a sub-atomic robot that is used in an electronic self-repair system, most notably Kryten. The nanobot's job inside him was to make sure that all his systems were operational, as a nanobot is subatomic they can change anything's component atoms into any other thing (such as turning a pencil's carbon arrangement into a diamond's carbon arrangement), a useful tool for repair. They eventually got bored of living inside the mechanoid and escaped from Kryten while he and the rest of the Red Dwarf crew were exploring the ocean world where the SSS Esperanto was found. The nanobots then escaped in a tiny version of Red Dwarf they created and were never seen again, leaving the crew in Starbug and Holly trapped on the planet they made out of the excess material from the large Red Dwarf. The crew believed to have found them in "Nanarchy" and they got them to rebuild Red Dwarf and give Lister a new arm, which he lost during "Epideme".
It was Holly, whom they found on the Red Dwarf planet (now back in his male form), who was the one to figure out where the nanobots were. The nanobots also resurrected the original Red Dwarf crew which later lead to the old Red Dwarf crew being arrested for stealing and destroying Starbug. To try and show them the truth the Starbug crew tried to prove their wild tale of the accident, nanobots, and three million years by trying to find the nanobots. In the end they were kept in computer simulation and did prove their story accidentally while in there, before being arrested for the fraud they tried to use earlier to escape. Holly then admitted that he in fact had created the new set of nanobots and told them to recreate the ship and resurrect the crew, to give Lister a diversion to keep him occupied and sane. Holly than commented that his plans had "all gone tits up" as they were taken to prison. According to Kristine Kochanski, nanobots are the same in her dimension.