"The Silmarillion" explains that the Dwarves received their language directly from their maker, Aulë. Aulë is one of the angelic Valar. He isn't capable of creating sentient life, but he tries anyway. He makes several Dwarves before he's caught by his own master, the creator god Ilúvatar. Ilúvatar forgives his servant for presuming he could give life and then grants consciousness to Aulë's creations. In this process, Aulë teaches the Dwarves a language that he specifically devised for them, and they use that language, nearly unchanged, for thousands of years.
They're particularly protective of their names, and practically no one outside of their own race knows what a Dwarf's name is in their own tongue. But in the "Lord of the Rings " book, Gandalf also says something that gives the idea that this secrecy may apply to their entire language. When the Fellowship of the Ring arrives outside of Moria, Gandalf tries to come up with the password. Initially, he's very confident, telling the group that he thinks it should only take a few tries and "I shall not have to call on Gimli for words of the secret dwarf-tongue that they teach to none."
This seems to heavily imply that the Dwarves aren't willing to teach their language to others, which begs the question, how does Elrond know it? And why is Durin so casual about telling him words in his "secret dwarf-tongue"?