He was once in the possesion of Jawas led by Nebit, and then sold to Owen Lars. R2-D2 was given orders by Princess Leia to get to Obi-Wan Kenobi under any means necessary, so R2 (supposedly) wrecked R5's motivater so R2 could get off the sandcrawler and find Obi-Wan instead of R5 getting off. After R5 malfunctioned, he was replaced by R2-D2 under the suggestion of C-3PO. The droid was stolen by a Squib as a rescue before the sandcrawler was damaged and killed the Jawas and Nebit and the droids malfunctioned after Sandtroopers came.