Jokers are one of those funny things -- sort of like the cotton in a bottle of aspirin. Many decks don't have jokers, and in most cases you can lose the jokers and it doesn't matter. So why include them? And another good question is, "Where did any of the cards in a deck come from?" Why are there 52 cards, with four suits and 13 cards to a suit?
This article from Encyclopedia Britannica offers a nice view on the origins of playing cards. It appears that the 52-card deck that we use today is a modification of part of the standard Tarot deck (the minor arcana), minus the knight cards. Probably around the 15th century the deck started settling into the modern form we know today.
The Joker, however, did not appear until sometime around the 1860s. At that time, the game of Euchre was extremely popular (it was later unseated by Bridge). In Euchre, under the British rules, there is a card known as the Imperial Bower (or Best Bower) that trumps all others. Decks of cards began to include a special imperial bower card, and it later morphed into the Joker card that we know today. According to this page, "The `Best Bower' was invented for use in the game of Euchre in which two of the Jacks are named Right and Left Bower; this happened during the 1860s in the USA. `Bower' is a corruption of the German word `Bauer' used in Alsace, from where Euchre or Juker originated as the ordinary word for `Jack'. This card evolved into the Joker during the 1870s. The Joker arrived in Europe in the 1880s along with the game of Poker. It was gradually incorporated into French-suited packs with 52 cards."
Here are several interesting links: