R2-D2 is an astromech droid built by Industrial Automaton. The design includes an assortment of tools for starship diagnosis and repair, as well as a magnetic roller assembly and small rocket engines for maneuvering around starships to make repairs in space. They have navigational computing capacity suitable for plotting hyperspace jumps for small interstellar vessels like N-1 and X-wing starfighters. Additional features include a computer interface, small sensor package, and a holographic recorder/projector system.
R2-D2 served as one of the maintenance droids for Queen Amidala's yacht. During the queen's escape from the Trade Federation blockade around Naboo, R2-D2 distinguished itself by performing an emergency repair to the yacht's shields, giving the crew the time they needed to fly past the Trade Federation's battleships. R2-D2 remained near the queen during the ship's brief stay on Tatooine and returned with her to Naboo. There, it boarded a Naboo starfighter that ended up being flown by Anakin Skywalker into a battle to destroy the Trade Federation's droid control ship, providing maintenance and control assistance during the battle.
R2-D2 accompanied Senator Amidala to Coruscant for a vote on whether to grant Chancellor Palpatine emergency powers in the event of war with a Separatist movement lead by Count Dooku. As she was threated by an assassin, it remained in her quarters at night to provide extra security, but its sensor package proved insufficient. Palpatine convinced Amidala to return to Naboo for her own safety, and R2-D2 travelled with her, and it remained with her when she accompanied her bodyguard, Anakin Skywalker, to Tatooine to search for his mother. From Tatooine, the group travelled to Geonosis, hoping to assist Obi-Wan Kenobi, who was captured after contacting them about Separatist activity there. On Geonosis, R2-D2 deactivated an automated droid assembly line to save the lives of Padmé and Anakin.
R2-D2 served as the maintenance droid for Anakin's Jedi starfighter during the Battle of Coruscant. When Anakin and Obi-Wan Kenobi boarded the Invisible Hand to find and rescue Chancellor Palpatine, R2-D2 hacked into the ship's computer system to aid their search. It accompanied Anakin to Mustafar following the Jedi Purge, and left the planet with Padmé and Obi-Wan to join Senator Organa on the Tantive IV. Following Padmé's death, Senator Organa took ownership of R2-D2 and assigned it to do maintenance on the Tantive IV.
R2-D2 was serving aboard the Tantive IV when the ship received a transmission from Rebel spies that contained the technical schematics for the Death Star. Imperial forces pursued the ship to Tatooine, where Princess Leia was attempting to contact Obi-Wan Kenobi for assistance. When her ship was disabled and boarded, the Princess download the plans into R2-D2, ordering him to abandon the ship in an escape pod and deliver the Death Star plans to Obi-Wan Kenobi, who she believed would be able to take them to her father on Alderaan.
R2 escaped with C-3PO, but the droids were captured by Jawas and sold to the Lars family before R2 could locate Kenobi. R2 fled the Lars moisture farm to find Kenobi, who was eventually found when the old Jedi rescued the droids and Luke Skywalker (who was pursuing R2) from Tusken Raiders. Kenobi hired Han Solo to take the group to Alderaan, only to find the planet destroyed and have their ship captured by the Death Star. R2 was able to hack into the Death Star's computers to both find Princess Leia in the station's brig and assist in their escape. Following their escape, Rebel engineers at the Yavin IV base extracted the Death Star plans from the droid.
R2 served as the in-flight maintenance droid for Luke's X-wing starfighter during the Battle of Yavin and was seriously damaged by a blast from Darth Vader's TIE fighter during the battle. It was fully repaired by Rebel technicians afterward.
Following the Battle of Hoth, R2 accompanied Luke to Dagobah (again serving as Luke's X-wing maintenance droid). He remained with Luke when the Jedi trainee left Dagobah for Bespin in an effort to rescue Leia and Han Solo from Darth Vader.
In Cloud City, R2 was separated from Luke but met with Leia and Chewbacca as Lando Calrissian helped them flee the city. R2 provided assistance by interfacing with the city's computer system, discovering in the process that Millennium Falcon's hyperdrive had been deactivated. Knowing how the ship had been sabotaged, R2 was able to reactivate the Falcon's hyperdrive to enable the group's escape.
Luke sent R2 with C-3PO to the palace of Jabba the Hutt on Tatooine, ostensibly as a gift to encourage the crime lord to release Han Solo. R2 was put to work serving drinks on Jabba's sail barge. When Jabba flew the barge to the Sarlacc pit to execute his enemies, R2 was present. The droid carried Luke's lightsabre in a concealed compartment and launched it just before Luke was thrown into the pit. As the now-armed Jedi attacked Jabba's defenders, R2 freed Leia and abandoned the barge before it was destroyed.
R2 accompanied Luke, Leia, and Han Solo on the mission to Endor to sabotage the deflector shield protecting the second Death Star. R2 was disabled by a blaster shot from a Stormtrooper while trying to hack into the computer system of the Imperial base to open a bunker door.