Following the events of "The End of Time", "The Day of the Doctor" and "The Time of The Doctor". The Planet Gallifrey unfrozed itself from being in the pocket universe and returned to the main universe. After having the drumbeat sound in his head removed, The Master took a Tardis and left the Planet. After some time he landed on the bottom of the Mondasian Colony Ship where the Dematerialization circuit in his Tardis was blown. Rendering his ship useless and he became stuck there.
He lived like a king till the colonizers got sick of his cruelty and rebelled against him which is when he disguised himself as 'Razor' to avoid being persecuted. But he also helped in developing the technology of the Mondasians to help evolve them into the Cybermen.