Davy Jones' locker is a rusty gym locker that is filled with smelly socks. In the episodes, it seems to have green goo at the bottom of it. The purpose of it is to torture whoever is in it.
The legend of "Davy Jones' locker" has existed in nautical folklore for many years, the first record being in 1726. In actual folklore, "Davy Jones' locker" is a phrase meant to refer to the bottom of the sea, where drowned sailors and wrecked ships end up. The name "Davy Jones" is likely a reference to the ghost of Jonah, the biblical figure who was swallowed by a giant fish, and was released by God after praying to be rescued. However, SpongeBob takes a different route, and uses the Monkees singer of the same name.
The Flying Dutchman returns after Mr. Krabs ends up in his territory. He tries to send Mr. Krabs down to the locker, but after a brief fight between the two, The Flying Dutchman ends up in the locker, where he is tortured by Davy Jones, who throws socks at him.