1660s, joque, "a jest, something done to excite laughter," from Latin iocus "joke, jest, sport, pastime" (source also of French jeu, Spanish juego, Portuguese jogo, Italian gioco), from Proto-Italic *joko-, from PIE *iok-o- "word, utterance," from root *yek- (1) "to speak" (cognates: Welsh iaith, Breton iez "language," Middle Irish icht "people;" Old High German jehan, Old Saxon gehan "to say, express, utter;" Old High German jiht, German Beichte "confession").
Originally a colloquial or slang word. Meaning "something not real or to no purpose, someone not to be taken seriously" is from 1791. Black joke is old slang for "smutty song" (1733), from use of that phrase in the refrain of a then-popular song as a euphemism for "the monosyllable." Lithuanian juokas "laugh, laughter," in plural "joke(s)" probably is borrowed from German.