A necessary fact is true across all possible worlds (that is, we could not imagine it to be otherwise). A possible fact is one that is true in some possible world, even if not in the actual world. This idea of possible worlds was first introduced by Gottfried Leibniz, although others have dealt with it in much more detail since, notably the American analytic philosopher David Lewis (1941 - 2001) in his theory of Modal Realism.
The concept of necessity and contingency (another term used in philosophy to describe the possibility of something happening or not happening) is also central to some of the arguments used to justify the existence or non-existence of God, notably the Cosmological Argument from Contingency (see the section on Philosophy of Religion for more details).