Unfortunately I haven't really read the books but as far as the movie franchise there's nothing really saying why Toothless has retractable teeth although it's most likely a common trait for Night Furies.
Toothless gets his name from his sets of retractable teeth. Toothless
is the only Night Fury seen thus far in the franchise, so his physical
appearance is all that can be studied to learn about Night Fury
Other than that I don't believe there's a canon answer. Although in real life Sharks actually have retractable teeth.
E-How Great White Shark Teeth
Jaws Like a Cat's Claw
The great white shark has rows of teeth behind the main ones. The
teeth are unattached to the jaw and are retractable, like a cat's
claw, moving into place when the jaw is opened. The great white sharks
teeth rotate on their own axis, moving outward when the jaw is opened
and inward when the jaw is closed. The great white shark's teeth are
linked to pressure and senor-sensing nerve cells, which give their
teeth high tactile sensitivity.
There are other animals that have retractable teeth like Anglerfish as well.
When the anglerfish’s jaw opens, it creates suction that pulls her victim inside. In some species,
retractable teeth spring down, trapping the meal. An expandable
stomach can hold fish larger than the anglerfish herself. High-speed
cinematography from the University of Washington has revealed that
anglerfish can pop open their mouths in just four milliseconds.