A stock motif which fantasy took over from the historical novel and historical romance. In reality, the licensed wit in motley was a phenomenon limited to a few courts in a period that lasted little over a century. The existence of some wise or half-wise court fools in literature from that century, notably the various fools in the plays of Shakespeare, helped set the pattern of the jester as the possibly knowing source of the truth others dare not tell the king.
Victor Hugo's Triboulet in The King Amuses Himself (1844), best-remembered in the play's adaptation by Piave and Verdi as Rigoletto (1851), and the protagonist of Edgar Allen Poe's "Hop-Frog" (1949) kill or attempt to kill the ruler who has dishonoured their womenfolk. W S Gilbert's Jack Point, in The Yeoman of the Guard (1888), is a sentimentalized version of the Romantic jester, who dies of a broken heart after losing his beloved to the hero; Point's sarcastic comments on a jester's conditions of employment have found echoes in fantasy, not least in Terry Pratchett's Wyrd Sisters (1988).
Jesters in fantasy come equipped with all this cultural baggage. They may simply be local colour indicating the decadence and depravity of a court; they may be the secret wise counsellor of the ruler or the ally of an intending usurper; they may be the Hidden Monarch enduring the shame of motley as disguise or humiliation (the lost king in Guy Gavriel Kay's Tigana  has been transformed into an idiot and deformed jester by his magician enemy, and can be redeemed and returned to normality only by death). They may, like Verence in Wyrd Sisters, be not so much the rightful king as the only competent person left standing.
The jester is the king's Shadow, like him set apart by costume and able, up to a point, to do anything he likes. [RK]