Slate ran an article about that a few years ago:
The Birth of Cool - Coul, coole, koole: How we got from cool temperatures to cool cats.
It came into English via Dutch/German cognates in the 9th century in its original temperature-related sense, eventually came to be applied metaphorically to human attributes, and by the 1920s was "firmly fixed as an unambiguous term of approval and even reverence."