In the first parable, a fox is trapped in a well. A goat approaches, looking for water. The fox proceeds to say how great and pure the water is, so the goat leaps down the well. The fox climbs on the goats back, promising to help the goat out later, which he then fails to do once out of the well. The goat, perturbed, complains, to which the fox replies "You foolish old fellow! If you had as many brains in your head as you have hairs in your beard, you would never have gone down before you had inspected the way up, nor have exposed yourself to dangers from which you had no means of escape."

The fable of the two frogs is similar. In it, one frog suggests to another frog that they live in the bottom of a well, since there will be plenty of water and food at the bottom. The other frog, being smarter, points out that once they go down there is no way out, thus showing the value of looking before you leap.

The first recorded use of the proverb in its current form is found in the Doce manuscript, which was written in 1350. The exact quote from that manuscript is: "First loke and aftirward lepe; Avyse the welle, or thow speke."

From http://www.literature.org/authors/aesop/fables/
and Dictionary of proverbs and their origins, by Linda & Roger Flavell