These are examples of the function of perfection, where evil itself reverts to good. However, all the earlier good times were caused by the function of the Sefirot in the mode of reward and punishment. In this mode, everything is evenly balanced. Either the Side of Holiness can hold sway over the Other Side, so that the Other Side is subdued and unable to cause harm, even though it does not actually revert to good but is tied up like a dog on a leash; or, Heaven forbid, the Other Side can hold sway and perpetrate the worst evils in its power.
Reward and Punishment in the Cosmic Balance
Kalach Pitchei Chokhmah 30:23