A necessary truth is one that could not have been otherwise. It would have been true under all circumstances. A contingent truth is one that is true, but could have been false. A necessary truth is one that must be true; a contingent truth is one that is true as it happens, or as things are, but that did not have to be true. In Leibniz's phrase, a necessary truth is true in all possible worlds. If these are all the worlds that accord with the principles of logic, however different they may be otherwise, then the truth is a logically necessary truth. If they cover all the worlds whose metaphysics is possible, then the proposition is metaphysically necessary. If a proposition is only true in all the worlds that are physically possible, then the proposition is true of physical necessity.
A permanent philosophical urge is to diagnose contingency as disguised necessity (Leibniz, Spinoza), although especially in the 20th century there have been equally powerful movements, especially associated with Quine, denying that there are substantive necessary truths, instead regarding necessity as disguised contingency. See also analytic/synthetic, a priori/a posteriori, Quine.