"a long time," 1821, often in phrases indicating something rarely occurring. Compare at the Greek calends (from an ancient Roman phrase alluding to the fact that the Greeks had nothing corresponding to the Roman calends), and the native in the reign of Queen Dick and Saint Geoffrey's Day "Never, there being no saint of that name," reported in Grose (1788). Nevermass "date which never comes" is from 1540s. Blue moon is suggested earliest in this couplet from 1528:
Yf they say the mone is blewe,
We must beleve that it is true.
Though this might refer to calendrical calculations by the Church. Thus the general "rareness" sense of the term is difficult to disentangle from the specific calendrical one (commonly misinterpreted as "second full moon in a calendar month," but actually a quarterly calculation). In either case, the sense of blue here is obscure. Literal blue moons do sometimes occur under extreme atmospheric conditions.
a "bright side" which proverbially accompanies even the darkest trouble; by 1843, apparently from oft-quoted lines from Milton's "Comus," where the silver lining is the light of the moon shining from behind the cloud.
Was I deceived? or did a sable cloud
Turn forth her silver lining on the night?
I did not err, there does a sable cloud,
Turn out her silver lining on the night
And casts a gleam over this tufted grove.
To which Thomas Warton added the commentary: "When all succour ſeems to be lost, Heaven unexpectedly presents the ſilver lining oſ a ſable cloud to the virtuous."