R2-D2 is a fictional male Robot astromech droid in the Star Wars series. The character was portrayed on screen by Kenny Baker. His allegiance / loyalty is to The Old Republic. R2-D2 is an astromech droid that travels on wheels on his three legs. R2-D2 is sometimes just referred to as Artoo for short. The middle leg is sometime retracted. R2-D2 is one of three characters that appear in all six films, the others being C-3PO and Obi-Wan Kenobi. Obi-Wan does appear in ghost form in the last two movies albeit in ghost form. The droid is primarily used for repairing items but throughout the movies he is used for other things, ensuring secrets messages getting to their intended targets is one.
The R2-D2 unit is assigned to provide repair duties for Padme Amidalas craft as it tries to break through the Trade Federations blockade of the planet and get to Coruscant. Due to receiving damage as it broke through the barricade, Amidala's craft lands on Tatooine. This is the first moment that R2-D2 first meets his sole mate, C-3PO. However the meeting is brief and C-3PO is left behind on Tatooine whilst R2-D2 leaves with the Old Republic.
R2-D2 provides support to Anakin Skywalker as he protects Padme Amidala from being assassinated both in her bedroom and throughout the film. R2-D2 journeys with Padme Amidala and Anakin Skywalker when Anakin wants to rescue his mother from the slave trader Watto. Anakin and Padme journey to Geonosis with the R2-D2 unit where the little robot meets with C-3PO again. During the battle on Geonosis, we see R2-D2 repair C-3PO who has swapped bodies with a Separatist droid. We also see R2-D2 fly for the first time, he has rockets in his feet to levitate.
R2-D2 provides repair cover for Anakin Skywalker as Anakin and Obi-Wan Kenobi attempt to break into General Grevious's battleship to rescue Vice Chancellor Palpatine who is being held hostage on the command ship. During the rescue, R2-D2 uses his rockets to escape from some droids which have cornered him. R2-D2 appearances become less as the film progresses, then at the end of the film, both R2-D2 and C-3PO's memories are erased to protect the existence of Anakin's children who will become Princess Leia and Luke Skywalker.
When the Tantive IV space craft is being attacked by a Star Destroyer, Princess Leia plants a message into the memory of R2-D2 and asks that it gets to Obi-Wan Kenobi before R2-D2 and C-3PO escape to the planet Tatooine below. In this film, the two robots take centre stage as the film follows them in getting information first to Obi-Wan Kenobi and then to the Rebellion.
During the time on Tatooine, R2-D2 and C-3PO get captured by Jawas and sold onto Lars and Beru Owen, the adopted parents of Luke Skywalker. R2-D2 shows a short clip of the message by Princess Leia and when the video is cut short, the restrainer belt on R2-D2 is removed enabling him to escape. R2-D2 is recoved by Luke Skywalker but he is attacked by Tusken Raider, also known as Sandpeople but is rescued by Obi-Wan Kenobi who takes them under his wing. Obi-Wan Kenobi is shown the video clip and agrees to take the two droids to Alderaan.
The four adventurers make their way to Mos Eisley where they agree a deal with Han Solo and Chewbacca to take them to Alderaan. When they reach the planet, the planet is destroyed and the craft that they are travelling in, the Millennium Falcon is captured and brought inside the Death star. Whilst Han Solo, Chewbacca and Luke SKywalker rescue Princess Leia, the two droids stay out of the way.
Once the Princess Leia has been rescued, the Rebels leave the Death Star and make their way to Yavin IV. The plans for the Death star are downloaded enabling the Rebels to attack. R2-D2 provides repair for Luke Skywalkers X-Wing as it takes part in the battle to destroy the Death Star.
R2-D2 plays a smaller role than he did in New Hope. After the Rebel Alliance escape from the Imperial assault on the Hoth base, R2-D2 goes with Luke Skywalker to Dagobah so that Luke Skywalker can learn from Yoda, the 900 year old green thing, his race is never revealed. When Luke leaves for Bespin to rescue Han Solo, R2-D2 joins him.
C-3PO and R2-D2 visit Jabba's Palace to bargain for the release of Han Solo. Unbeknown to the two droids, Luke Skywalker's message offers the droids for the release of Han Solo. Jabba uses the robots as servants. C-3PO provides translation services for Jabba and R2-D2 is nothing more than a drinks servant. When Luke Skywalker causes mayhem and disorder on the hovership, the two robots make an exit but fall into the sand.
Han Solo, Princess Leia, Lando Calrissian, Chewbacca and C-3PO head to the Rebel fleet where C-3PO is to join the assault on the shield generator on the Moon of Endor led by Han Solo. During the time on the moon of Endor, C-3PO gets worshipped as a God by Ewoks because of his golden complexion. The Ewok release the Rebel assault team and make friends. For the battle on Endor, the two droids stay out of the fighting, they avoid the battle.
R2-D2 and his robot friend C-3PO have a cameo appearance in Rogue One where C-3PO makes a comment after Jyn Erso and Cassian Andor leave the base on Yavin IV to steal the Death Star plans from the Imperial base on Scarif.
For most of the film, R2-D2 languishes at the Resistance base, longing for the return of Luke Skywalker. Near the end of the film, R2 comes back to life but his involvement is nowhere as much as it used to be.
In the Last Jedi, R2-D2 has just a cameo role again. Before the film was released, Kenny Baker, the actor who had controlled the robot for the previous films had passed away. Jimmy Vee stepped into the role to take command of the robot.
As R2-D2 is non visual role and non speaking, this character will continue to appear in future films. Both C-3PO and R2-D2 got slightly side-lined as the Rebel Alliance robots in favour of BB8, a robot ball machine.