The character was first seen in A New Hope, and was the Droid who malfunctioned and led to Luke and Owen taking R2-D2 instead.
The character was last seen on Tatooine, which obviously leaves open the possibility that The Mandalorian takes place (at least in part) on that planet or that someone from Tatooine transported him there.
R5-D4: R5-D4’s involvement was teased by Jon Favreau, although the picture doesn’t guarantee he’s actually a part of the show.