This appeared in the southern states of the USA about the middle of the nineteenth century. It was used by tradespeople in New Orleans for a small extra item or bonus that they gave to their most favoured customers. The idea of a bonus is still to be found:
Laughlin said the festival offers music lovers a smorgasbord of options — for both food and entertainment — and gives local musicians a little bit of lagniappe: the chance to showcase their talent to the world.
Hutchinson News (Kansas) 11 Apr. 2014.
The best early description of the word was written by Mark Twain, in his book Life on the Mississippi of 1883:
We picked up one excellent word — a word worth traveling to New Orleans to get; a nice limber, expressive, handy word — “lagniappe”. They pronounce it lanny-yap. ... The custom originated in the Spanish quarter of the city. When a child or a servant buys something in a shop — or even the mayor or the governor, for aught I know — he finishes the operation by saying “Give me something for lagniappe”. The shopman always responds; gives the child a bit of licorice-root, gives the servant a cheap cigar or a spool of thread, gives the governor — I don’t know what he gives the governor; support, likely.
Despite its Italian look, lagniappe is actually a modified form of a Louisiana French creole term that derives from the New-World Spanish la ñapa, a gift, which in turn has its origin in a Quechua word yapa for a gift or tip.