The doctrine or belief that in the system of things all that happens, the undesirable no less than the desirable, is for the best
The phrase "the best of all possible worlds" was coined by the German polymath and Enlightenment philosopher Gottfried Leibniz in his 1710 work Essais de Théodicée sur la bonté de Dieu, la liberté de l'homme et l'origine du mal (Essays of Theodicy on the Goodness of God, the Freedom of Man and the Origin of Evil), more commonly known simply as the Theodicy. Wikipedia