You really ought to read I Have No Mouth, and I Must Scream. The author has already thought of basically the same thing and written a rather compelling yet disturbing short story about. In 1967, no less.
But if we're going to give unfathomable power to such an AI, it's not much more of a leap to give it the ability to resurrect people from the past and subject them to whatever it desires.
Taking it even one step further and comparing it to the Simulation Hypothesis [1], perhaps we're already there. The machine might be making us live our lives again only at some point to surprise us with some unthinkable horror or delight.
If such a machine arises and is capable of these feats, then we might currently be living in re-simulations of our past lives that have already ended.