Or rather, it has a tune which was first recorded in the 18th century. But who knows how old it really is? Things can exist in the folk tradition for ages before someone literate takes note of them.
It sounds like a dance tune to me. A country dance. There's a version out there on YouTube where it's being played on a hurdy-gurdy- and that seems just about right. I picture a dusty 17th century French town and an old man with a hurdy-gurdy and a monkey on a string (why not?) standing on a street corner repeatedly cranking it out. In all its many versions it has a quality of going-on-foreverness. You've started, it's catchy, it goes round in a loop, so why should you ever stop?
It first emerged accompanied by a set of French lyrics about the Duke of Malborough. Wikipedia pegs this to the false report of his death that circulated after the Battle of Malplaquet in 1709- but that can only be conjecture.
In this form it was a favourite of Marie Antoinette's- who learned it off the Dauphin's wet nurse- the excellently named Madame Poitrine. Once royalty had taken it up it went viral. Goethe said he was sick to death of hearing it. Various classical composers wove it into their compositions- most notably Beethoven, who used it in a novelty piece called "Wellington's Victory"- written to be played on a machine called the Panharmonicon (the invention of mechanical whiz kid and entrepreneur, Johann Maelzel) which mimicked the sound of an orchestra. Beethoven knew the piece was beneath his dignity but told his critics, "What I shit is better than anything you could think up"- which was entirely the case.
As it spread the tune acquired new sets of words. In the English-speaking world it's best known as "For he's a Jolly Good Fellow." The lyrics about the bear are probably American, but nobody knows how old they are. I imagine them coming out of a camp-fire sing-along. I reckon some early 20th century scout leader is to blame.
But it's such a good tune. No wonder it won't lie down and die. It's jolly, and bouncy but with a plaintive edge to it. The best set of words are still the earliest ones- with the famous Malbrook going to war, dying, being buried and having a rose tree planted on his grave with a nightingale singing from its branches. They're silly but also a little sad- just like the tune itself...