An anomaly cage was a machine constructed by the Cult of the Heretic. Its function was to allow its user to "regenerate" the universe and start anew in the user's image. It needed a Time Lord to use it.
After the Heretic was taken by the Time Lords, the Cult needed another Time Lord to activate the cage. They made a deal with the Master, who had come to offer them his DNA in return for a position of power in their recreated universe. They manipulated him into coming into contact with his past self, claiming that they wanted him to kill his past self to prove his dedication to their cause. After the Master had crippled his past self, the Cult betrayed the Master by knocking out the future Master and transferring the past Master into his future self, leaving the older Master's mind in his past self.
The two Masters, after returning to their normal bodies, then returned to the Cult's headquarters and killed all of the members. They planned to use the anomaly cage to recreate the universe but were stopped by the Seventh Doctor, who then made sure that the universe remained practically unchanged by its regeneration, his only change being to save the life of his temporary companion Jemima so that she was never killed by the Master. (AUDIO: The Two Masters)