Sator wanted to destroy the world because he was dying and in pure selfishness of if he can't have it, no one can. The algorithm is a machine that would invert time and would catastrophically end everything.