Gottfried Wilhelm Leibniz was born on 1 July 1646 in Leipzig, in the Holy Roman Empire, and trained in law and philosophy before entering a long career of court and diplomatic service, chiefly to the House of Hanover, alongside his independent work in mathematics, logic and metaphysics. His most influential contribution to religious thought is the concept of theodicy, a term he himself coined for the systematic philosophical defense of God's justice and goodness against the existence of evil, argued at length in his 1710 work Theodicy.
Leibniz's central theodicean claim, that this is the best of all possible worlds a perfectly good and rational God could have created, reasoned that any evil present is a necessary consequence of a greater overall good rather than a flaw in divine planning, a position that became famous partly through Voltaire's later satirical attack on it in Candide. He died in Hanover on 14 November 1716, working until near the end of his life on the Chinese material that occupied his final major treatise.
Leibniz developed his theodicy in explicit dialogue with the skeptic Pierre Bayle, who had argued that the coexistence of a perfectly good, all powerful God with the world's evident evil was philosophically indefensible; Leibniz's Theodicy is structured throughout as a direct, systematic answer to Bayle's challenge rather than an independent treatise, making it as much a work of philosophical argument as of theology, aimed at a specific, named opponent's specific, published objections.