A New Sith, or Revenge of the Hope: "Consider: at the end of RotS, Bail Organan orders 3PO's memory wiped but not R2's. He wouldn't make the distinction casually. Both droids know that Yoda and Obi-Wan are alive and are plotting sedition with the Senator from Alderaan. They know that Amidala survived long enough to have twins and could easily deduce where they went. However, R2 must make an impassioned speech to the effect that he is far more use to them with his mind intact: he has observed Palpatine and Anakin at close quarters for many years, knows much that is useful and is one of the galaxy's top experts at hacking into other people's systems. Also he can lie through his teeth with a straight face. Organa, in immediate need of espionage resources, agrees.
For the next 20 years, as far as 3PO knows, he is the property of Captain Antilles, doing protocol duties on a diplomatic transport. He is vaguely aware of the existence of the princess but doesn't know much about her. Wherever 3PO goes, being as loud and obvious as he always is, his unobtrusive little counterpart goes with him. 3PO is R2's front man. Wherever they land, R2 is passing messages between rebel sympathisers and sizing up governments as potential rebel recruits - both by personal contact and by hacking into their networks. He passes his recommendations on to Organa. "