Why is a dungeon there? Well, someone had to build it, but that's a topic for later. Why is it in your story? Why is your character going to one? It has a purpose to serve. What sort of purpose? Well, whatever reasons your character is going to one in the first place.
A term like "ecology" means specific things in gaming context. So many things in games come about on fiat. Why do trolls regenerate? Regenerating monsters are interesting foes. But being a proto-intelligent humanoid with regenerative powers is strange. How does it work? How do they work? What is their culture like? How do they go about living? These questions are unanswered.
Crawling around in dank, poorly lit underground tunnels, on the quest for treasure and mindful of monsters and traps: this is THE typical adventure. It has always slightly reminded me of my college years, but that is another story. This prototype has been around for quite some time. The game, after all, is called "Dungeons and Dragons."