It's because Moria used the have good connection with the elves of eregion. (the area west of Moria) They both prospered in the trade with eachother and the gate was made by the elf Celebrimbor (he also crafted the three elven rings) and the dwarf Narvi. The two greatest craftsmen of their time. The doors normally stood open with a guardsmen guarding it. But they closed it when Sauron waged war in Eriador in the second age. So they closed it and put an elvish password on it, since the dwarves wouldn't teach any outsiders their language.
replydetachattach picture