Full Idea
Although the world is not metaphysically necessary, such that its contrary would imply a contradiction or logical absurdity, it is necessary physically, that is, determined in such a way that its contrary would imply imperfection or moral absurdity.
Gist of Idea
The world is physically necessary, as its contrary would imply imperfection or moral absurdity
Source
Gottfried Leibniz (On the Ultimate Origination of Things [1697], p.139)
Book Reference
Leibniz,Gottfried: 'Philosophical Writings', ed/tr. Parkinson,G.H.R. [Dent 1973], p.139
A Reaction
How does Leibniz know things like this? The distinction between 'metaphysical' necessity and 'natural' (what he calls 'physical') necessity is a key idea. But natural necessity is controversial. See 'Essentialism'.