Phrase Finder suggests this phrase plays on the two meanings of “cool” as a low temperature (cucumbers are cool to the touch) and imperturbable. The phrase was first recorded in a poem in 1732. The Online Etymology Dictionary adds that the idea that cucumbers feel cool was “confirmed by science in 1970: inside of a field cucumber on a warm day is 20 degrees cooler than the air temperature.” I am not surprised that a poet would create a memorable phrase, but for “cool as a cucumber” to last for nearly 300 years with its meaning intact is quite an accomplishment.