According to Britannica.com, the 52-card deck that we use today is a modification of part of the standard Tarot deck, made up of the Major Arcana and 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.
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.