Shakespeare scholars will know Costard as a clown in Love’s Labour’s Lost. I guess he was given that name because it was then a slang term for the head. Shakespeare puts the same word into the mouth of the First Murderer in Richard III when giving instructions for the disposal of the ill-fated George, Duke of Clarence: “Take him on the costard with the hilts of thy sword, and then chop him in the malmsey-butt in the next room”. George, brother of Richard III, is traditionally said to have been drowned in a butt of malmsey (a large barrel of a strong sweet wine from Madeira and other places); what must originally have been a sarcastic quip on the death of a drunkard has now become fixed in legend.
A costard was originally a native English apple, a large medieval variety that no longer exists. Nobody knows why it got that name, though there is a suspicion that it comes from an Old French word coste for a rib, as the costard was described as angular in shape with pronounced ridges.
The word was still around in both senses at the beginning of the nineteenth century. By then, though, it most commonly appeared in disguise in the name of sellers of fruit: costermongers, so called because they originally sold this type of apple, though by that date they sold all manner of fruit and vegetables and also fish. Even in such lowly occupations there was a hierarchy: a person who sold fruit from a basket was a mere hawker, but a costermonger had the dignity of a handcart or sometimes a cart pulled by a donkey. Costermongers had the reputation of being tough, hard-living, foul-spoken, often drunk, and always ready for a fight.
The word, by the way, has no connection with the West Indian fruit custard apple. Though the apparent similarity in name is striking, the word custard here has a different origin. It is said that the pulp of the fruit reminded Europeans in colour and consistency of a custard, and the fruit is roughly apple-sized; this was sufficient to create an entirely misleading English name.