Gottfried Wilhelm Leibniz, answered from the texts and cited to the page.
The distinction runs as follows. Every truth is either one whose contrary implies a contradiction, or one whose contrary implies no contradiction whatever. The former are necessary truths; the latter are contingent.1 In necessary truths, the connection between predicate and subject can be made fully explicit by a finite analysis of terms. One substitutes definitions for what is defined, step by step, until the proposition resolves into an identity — something self-evidently true, affirming the same of itself.
That every duodenary number is senary can be demonstrated in exactly this way: resolve the terms into their prime factors, and the inclusion of the predicate in the subject stands before you, undeniable, with geometrical rigor.2 The analysis terminates; the demonstration is complete. In contingent truths, the analysis never terminates. The predicate is still contained in the subject — that much is common to every true proposition — but the series of reasons for reasons proceeds to infinity, so that no finite mind can ever draw the demonstration to a close.3
There is always an underlying reason for the truth; it is simply that only God, who alone traverses an infinite series in a single stroke of mind, comprehends it perfectly.4 This is also why God alone knows contingent truths a priori, seeing their infallibility otherwise than through experience.5 The upshot for freedom and contingency is decisive.
Because no finite analysis can reduce a contingent proposition to an identity, nothing about the contingent order is logically forced upon us the way twice-two-is-four is forced. In necessary propositions, the reason necessitates; in contingent propositions, it inclines — and inclining without necessitating is precisely the structure that leaves room for things to have been otherwise.6
God chose this world because it has more reason for existing than any other would in its place, but that choice was free, not compelled by logical necessity.7
a necessary proposition is one whose contrary implies a contradiction. Every identical proposition and every derivative proposition resolvable into identical propositions is of such a kind.On Freedom (1689?), pp. 179–180
if by a ternary, senary, and duodenary number we understand one divisible by 3, 6, 12, then we can demonstrate the proposition that every duodenary number is senary.On Freedom (1689?), pp. 179–180
In contingent propositions, however, the analysis continues to infinity through reasons of reasons, so that we never have a full demonstration, although there is always an underlying reason for the truth.The Shorter Leibniz Texts, p. 111
the reason is understood completely only by God, who alone traverses the infinite series in one stroke of mind.On Contingency (1686?), pp. 69–70
This is also the reason why God alone knows contingent truths a priori and sees their infallibility in a way other than through experience.On Freedom (1689?), pp. 179–180
in necessary propositions, that reason necessitates; in contingent propositions, it inclines.On Contingency (1686?), pp. 69–70
this seems to be common to existing things, both necessary and contingent, that they have more reason for existing than others which might be assumed in their place.The Shorter Leibniz Texts, p. 111