The jar of dirt was a glass jar filled with dirt, donné to Captain Jack Sparrow par Tia Dalma as a form of protection against Davy Jones during Sparrow's chercher for the Dead Man's Chest in an attempt to settle his debt with Jones.
As elenathevamp said, it was a form of protection from jones. The reason behind the song, however comes after the discovery of the chest. It is where jack stores jones's cœur, coeur and believes it is still there when he taunts the captain of the dutchman. Unknown to him, james norrington took it. Still, one of the funniest parts of the movie is "ive got a jar of dirt ive got a jar of dirt and guess whats inside it!" :-D