A "blue moon" once meant something impossible or at least highly unlikely, much like the expression "when donkeys fly!" This was apparently the usage as early as the 16th century.
Then in 1883, the explosion of Krakatau in Indonesia threw enough dust into the atmosphere to turn worldwide sunsets green and the moon blue. Forest fires, prolonged drought and volcanic eruptions can still do this. So a blue moon became synonymous with something rarehence the phrase "once in a blue moon."
The connection of a blue moon with the calendar apparently comes from the Maine Farmers Almanac published in 1937. The almanac relies on the tropical year, which runs from winter solstice to winter solstice. In it, the seasons are not identical in length because the earths orbit is elliptical rather than circular. Further, the synodic month is approximately 29.5 days, which doesnt fit evenly into a 365.24-day tropical year, nor into seasons only approximately three months in length.
Most tropical years have 12 full moons, but occasionally there will be 13, so one of the seasons will get four. They called the occasional third full moon in that season in which there happened to be four a blue moon. (The full moons closest to the equinoxes and solstices already have traditional names.) J. Hugh Pruett, writing in Sky and Telescope in 1946, misinterpreted their version to mean the second full moon in a given month. That version was repeated in a broadcast on National Public Radios Star Date in 1980, and the definition has stuck!
Although it is true that the phrase comes from a folk tale, the current folk tale isnt very old. So when someone talks about a blue moon today, they are referring to the second full moon in a month.