A while ago I read the Ilias and the Odyssea by Homerus (probably not the English spelling, but English is my second language and I don't feel like looking it up).
One scene, in which Achilles kills a bunch of people in a river, really worked its way into my mind. The river had a god (or maybe it was a god or both or neither, I don't know the specifics of ancient greek metaphysics as portrayed in these stories) who got pissed about the disrespect Achilles was showing by killing all these people in its clean water without any offerings given beforehand. So the river god tries to kill Achilles with a flash flood. And without a bunch of other gods looking out for Achilles that would have been his end.
Achilles and the river Scamander by Alexander Runciman
This made me think of the concept of the mythic underworld. Most often I have seen it explained as the dungeon being an otherworldy place that hates the players and actively tries to oppose their advance. It is an interpretation of old school dungeons that tries to account for the weirdness that could be found in some of them, as well as the selectiveness with which certain obstacles affect those the dungeon (stuck doors never hindering monsters is one example of this that I have seen multiple time).
The dungeon being a place particularly hostile towards PCs seems very similar to me to the river being hostile towards Achilles. So why not give the dungeon, each particular dungeon, a god/demon/spirit who resents the PCs for entering their domain and therefore actively oposses them. Just like the flash flood was out to get Achilles, so the stuck doors, the deadly traps and horrible monsters are out to get the PCs. It is deliberate, targeted and personal.
To me, this would make sense in a world that is animist-like, with minor deities inhabiting basically anything. You could even do the Princess Mononoke thing and give these deities physical embodiments which can be harmed. Something about the players planning to take down the physical manifestation of the dungeon they are raiding seems really fun to me.
Animism has facinated me for a while now, and I have been doing some thinking about how it coul relate to magic as well. I'll make that a separate post though.