Luke hid his Lightsaber in R2D2 to aid in the rescue.
So, how did Luke know that Jabba would bring R2D2 where they would be executed?
I could guess "Force vision", but I'm looking for canon confirmation.
Science Fiction & Fantasy Stack Exchange is a question and answer site for science fiction and fantasy enthusiasts. It only takes a minute to sign up.Sign up to join this community
As Valorum points out, it is very like a Hutt Crime Lord to flaunt his spoils. This is a person known for keeping a giant carnivore under his living room for the express purpose of taunting and executing people who displease him. Everything else we see Jabba do confirms this trait:
Jabba is practically a Bond villain (more Tropes). Luke knows that Jabba will be inclined to keep R2 and C3PO close at hand, because Jabba is an arrogant fool. He even employs other arrogant fools down to the droid he uses to enslave/"process" other droids. This droid could easily be reprogrammed to be more cautious and detect traps and deceptions in other droids in Jabba's palace, or have just do a simple x-ray, but Artoo slips right through with a weapon of Sith destruction. R2-D2 is a skilled astromech droid who could presumably be put to good use fulfilling his designed duties on one of many starship in Jabba's criminal armada, but instead is given a job serving drinks. How could Luke know? is your question, but a key to understanding that is Why?.
The RotJ on-screen plot contrivance only reveals that R2-D2 was assigned to the barge by the droid-overseer EV-9D9 without any indication as to the root cause for the waitstaff opening.
You're a feisty little one, but you'll soon learn some respect. I have need for you on the master's sail barge, and I think you'll fill in nicely.
Presumably Luke would have done his research before sending R2 and C-3PO into the lions den and known what types of jobs they would be assigned to. Even if Luke didn't have a Force Vision, Jabba isn't exactly a private person. He runs a sprawling crime organization and a palace that has shady and disreputable people passing through it all the time. His behavior and persona are well known to the galaxy. Even if they weren't, we know Lando was already on the inside, capable of gathering intelligence or even sabotaging the previous waiter-bot and interpreter ensuring that C-3PO and R2 will have duties assigned to them.
Even if Jabba (or more precisely EV-9D9) doesn't command R2D2 be brought along, R2D2 is an intelligent, self propelled, self aware android. Luke probably told R2, when storing the lightsaber inside his dome, what it was for and under what circumstances R2 should try to get near to Luke and get him the lightsaber. I don't think it's much of a stretch of the imagination to think R2 could discover the execution plans and get onto the sail barge on his own initiative. R2 could also arrange a handoff to Lando who is still undercover and winds up much closer to Luke's execution than even R2.
R2 does, after all, fake a malfunction to get a restraining bolt removed and complete his espionage mission to find Obi-Wan Kenobi, gather intelligence from the Cloud City central computer, fix a hyperdrive and lure a legion of Stormtroopers without direct orders. This is strong circumstantial evidence that R2 is actually one of the prime conspirators of the rebel alliance and one of the real hero's of the Star Wars duo-(soon-to-be-tri-)trilogy.
Regarding cannon evidence, the subject of R2D2 and C3PO is touched upon in the short story anthology Tales from Jabba's Palace, presumably in A Bad Feeling: The Tale of EV-9D9; plot summaries mention Lando Calrissian, but I can't find a solid reference for commenters Jeff and Codes-With-a-Hammer's recollections of a sail barge droid job opening being the result of intentional sabotage. One thing that is in evidence is that EV-9D9 is apparently an outcast and fugitive from Cloud City, which would lend credence to Lando being the experienced choice for infiltrating around EV-9D9.
This is of course 'Legends' canon. For Disney cannon, you're out of luck.
Frankly, their plan stinks.
It should have worked something like this;
The droids arrive and deliver their message (and themselves) to Jabba. As a Jedi, Luke is honour-bound to give him the opportunity to simply surrender and more importantly this puts the lightsaber in easy reach if Luke should need it.
Lando infiltrates the base and identifies Han's location, releasing him if possible.
Leia infiltrates the base (with Chewie as bait) and releases Han and Chewie and the droids.
But what actually happens is;
The droids deliver themselves as scheduled.
Lando is useless.
Leia gets recognised almost immediately (after having handed over Chewbacca to Jabba), then gets stripped and sexually abused.
As far as I can see, had the plan had gone correctly, there would have been no need for Luke to turn up at all and the droids would have escaped with Leia (or just been left with Jabba).
In reference to the specific question of why R2D2 was on the sailbarge, it's likely that Jabba would have seen the value in a well-trained astromech droid. He'd want to keep his new "toys" on display and he certainly would have wanted Luke to see them in order to further humiliate him on his poor decision-making (which is why he has C3P0 read his pronouncement to them).