I suppose you would say that the role of Patroclus is to be a sacrificial lamb in order to get Achilles to come back to the battle.
Achilles has been sulking in his tend because he was forced to give Briseis (the woman he had been given as a prize of war) up. But then Patroclus gets killed by Hector. Patroclus is Achilles's closest friend and Achilles is absolutely engraged by his death. So that is when and why. Achilles returns to battle when Patroclus is killed because he is so angry at his best friend's death.
If, by "when" you mean where in the book, it's in Books 18 through 20.