Giocare, it might not surprise you, means to play, so the links between the two words are pretty clear. Interestingly though, both words can be traced all the way back to the Proto-Indo-European *iok-o- (word, utterance), from the root *yek- (to speak).
I find it fascinating that the word joke has come so directly from words meaning simply to speak or word without much change. Does it perhaps suggest that joking is fundamental to our lives that we’ve been doing for as long as we’ve had language? (and perhaps there were practical jokes before language developed) I can certainly understand how a few good jokes would make the evenings pass more quickly during the long, dark winters of ancient Northern Europe.
And most of us still joke quite a lot, even if we’re not so conscious of it. If you think about all the things you say in a day, how many are intended to provoke at least a slight smile or laugh? Even if they don’t have the narrative or question-and-answer structures we might associate with the word joke, they serve the function of a joke, just like they did way thousands of years ago for our ancestors.