The Homeward Bounders by Diana Wynne Jones

A young boy from our world is suddenly left behind when everyone else disappears and finds himself told he must become one of the Homeward Bounders—people condemned to hop unpredictably between alternate worlds as pawns in a cruel, cosmic game run by aloof immortals. As he drifts through shifting realities, he meets other exiles, learns the terrifying rules that trap them, and must use courage and cunning to challenge the players and try to find a way back to the life he lost.

Purchase from Bookshop.org