To protect his sister and himself from Britannia's politics following Japan becoming Area 11 he made a deal with the Head of the Animusphere Family. In exchange for becoming a master for Chaldea when the time came Lelouch and Nunnally would be hidden and protected. Lelouch travels to Chaldea to fulfill his end of his agreement unaware of what is awaiting him. Has a Tvtropes page.
Lelouch expected many things after his death. What he didn't expect was to find himself in the war between seven wizards and historical figures. Still, the prize seems nice enough so he might as well take it. Not to mention working with a fellow demon might be a unique experience.
Sakura, Arturia, Medusa, Illya, and Bazett participate of the fifth grail war had lost the battle and about to witness Angra Mainyu birth but it was stop by the counter guardian. With his Noble Phantom he save the girls life and give them the Holy Grail for their happy ending but the girls seeing his life use the wish to give Lelouch Vi Britannia his happy ending.