There's many a slip 'twixt the cup and the lip is a very old proverb, similar in meaning to "don't count your chickens before they hatch". It implies that even when a good outcome or conclusion seems certain, things can still go wrong.
The English proverb is almost identical with a Greek hexameter verse, Πολλὰ μεταξὺ πέλει κύλικος καὶ χείλεος ἄκρου (Much there is between the cup and the tip of the lip). This verse was proverbial at the time of Aulus Gellius (2nd century A.D.), who mentions it in his comment on the Latin phrase inter os atque offam (between the mouth and the morsel) used by Marcus Cato. The Greek verse is attributed to Palladas in The Greek Anthology (X, 32), but that is manifestly erroneous, since Palladas lived two centuries after Aulus Gellius. The Loeb Classical Library edition of the Anthology says that the verse is "a very ancient proverb, by some attributed to Homer". There is a reference to the many things that can intervene between cup and lip already in an iambic verse by Lycophron (3rd century B.C.) quoted by Erasmus.
According to a story about the proverb, the verse was a comment by a seer who told Ancaeus, who was setting out on the perilous enterprise of the Argonauts, that he would never taste wine from his newly planted vineyard. On his safe return, Ancaeus filled a cup with the first wine from his vineyard and reproached the seer for what appeared to be a false prophecy. The seer responded with the verse and just then an alarm was raised that a wild boar was destroying the vineyard. Without tasting the wine, Ancaeus rushed out and was killed by the boar.
The proverb may have been inspired by a situation described, without the proverbial phrase, in Homer's Odyssey, Book xxii 8-18 (from c. 850 B.C.), where Odysseus kills Antinous, who "was on the point of raising to his lips a fair goblet, a two-eared cup of gold, and was even now handling it, that he might drink of the wine, and death was not in his thoughts".