Cool here means imperturbable rather than having a low temperature. Cucumbers are cool to the touch.
First recorded in John Gay's Poems, New Song on New Similies, 1732:
"I ... cool as a cucumber could see The rest of womankind."
MANILA, Philippines – Cucumber has been squeezed for juice since it first appeared in southern Asia 3,000 years ago, when it was first discovered to cool the body and cure many ailments. A substantial amount of juice is extracted from cucumbers which contain 96 percent nutrient-filled water.