A long time ago in a galaxy far, far away....
Nicknamed "Red" by Luke Skywalker, R5-D4 is the astromech whose sudden breakdown at the Lars homestead changed galactic history. The breakdown was deliberate. Held by Jawas after an earlier stint with the rebellion ended in a memory wipe, the droid was persuaded by R2-D2 that the fate of the galaxy depended on R2 being sold. When Owen Lars chose R5 instead, the droid blew its own head plate, so the Lars family bought R2-D2 and the Death Star plans reached Luke and Obi-Wan Kenobi. R5 then played dead while stormtroopers slaughtered its Jawa owners and set off to find the Rebellion. The historian Voren Na'al later bought and repaired it, and it served with Carson Teva's X-wing squadron until the Empire fell. After another memory wipe it drifted back to Mos Eisley, trained under EV-9D9 at Chalmun's Cantina, and ended up in Peli Motto's hangar, where it helped Din Djarin and was later reunited with R2-D2. Peli eventually sold the reluctant droid to Djarin for his quest to Mandalore. There R5 confirmed the planet's air was breathable, fetched Bo-Katan Kryze to rescue Djarin, and helped retake the homeworld by shutting down the shields of Moff Gideon's base. Afterward it joined the New Republic's Adelphi Rangers.
Serving a master in Mos Espa, R5-D4 is out in the streets when Anakin Skywalker returns to Tatooine to search for his mother.
After working with the early rebellion against the Empire, R5-D4 ends up with a Jawa clan. The Jawas wipe its memory, and it spends years stored in their sandcrawler hoping to be sold.
The Jawas capture R2-D2 and put him in the same sandcrawler. R2 starts sabotaging R5 to remove the competition, then stops and explains that the Rebellion needs him to be sold.
Owen Lars picks R5-D4 over R2-D2. R5 deliberately blows its head plate, faking a bad motivator, so Owen buys R2-D2 instead and the Death Star plans reach Luke Skywalker.
R5 plays dead while stormtroopers kill the Jawas, then sets off along their trade route to look for a new owner and the Rebellion.
While researching Luke Skywalker's origins, the Alliance historian Voren Na'al finds R5-D4 on Tatooine, buys it cheaply, repairs its motivator and records its account of the droid sale.
R5 is assigned to Carson Teva's X-wing squadron and takes part in several classified missions during the Galactic Civil War.
After the Battle of Jakku, Na'al wipes R5's memory and returns it to Tatooine, where it wanders the dunes before reaching Mos Eisley.
EV-9D9 finds R5 by the cantina's garbage masher and takes it on as a trainee bartender. When a Trandoshan patron kicks R5, EV-9D9 poisons his drink and leaves with the droid.
EV-9D9 brings R5 to Hangar 3-5, and Peli Motto takes it in. R5 projects a map of Tatooine that shows Din Djarin where Mos Pelgo is.
R5 is at Peli's hangar when R2-D2 arrives with Grogu in Luke Skywalker's X-wing.
Peli sells a reluctant R5 to Din Djarin at half price, and it joins his mission to the Living Waters of Mandalore.
R5 goes into the ruins to take an air sample and confirms the atmosphere is breathable. After Djarin is captured, R5 and Grogu bring Bo-Katan Kryze from Kalevala to rescue him.
R5 passes the covert's location to Carson Teva, flies as co-pilot against Gorian Shard's pirates, and is with Bo-Katan when she finds the Mandalorian fleet on Plazir-15.
At Moff Gideon's base, R5 gets past its droids, sends the schematics to Djarin and shuts down four shields, then escapes on its rocket boosters before the base is destroyed.
After Mandalore is liberated, R5 enters New Republic service at Adelphi Base.