Wikipedia claims that the term was introduced by Pearson in On the theory of contingency and its relation to association and normal correlation. Pearson does indeed seem to have coined the term. He says (referring to two-way tables):
I term any measure of the total deviation of the classification from
independent probability a measure of its contingency. Clearly the
greater the contingency, the greater must be the amount of association
or of correlation between the two attributes, for such association or
correlation is solely a measure from another standpoint of the degree
of deviation from independence of occurrence.
(Pearson, On the Theory of Contingency and Its Relation to Association and Normal Correlation, 1904, pp. 5-6.)
Pearson explains in the introduction that he and others had previously considered categorical variables as ordered in all circumstances, and had analysed them as such. For example, in order to analyse eye colour,
one arranged eye colours in what appeared to correspond to varying
amounts of orange pigment [...]
The point of the paper is to develop methods for analysing categorical variables without putting some artificial ordering on the categories.
The first use of the term contingency table appears on page 34 of the same paper:
This result enables us to start from the mathematical theory of
independent probability as developed in the elementary textbookss, and
build up from it a generalized theory of association, or, as I term
it, contingency. We reach the notion of a pure contingency table, in
which the order of the sub-groups is of no importance whatever.
Thus, contingency is supposed to mean "non-independence". The word contingency is used because two events are contingent if the outcome of one is contingent upon - i.e. dependent upon - i.e. not independent of - the outcome of the other.
In other words, it's related to definition 4 from this Merriam-Webster page.