These things aren't related. Like, at all. You can absolutely have a strong story to a dungeon despite it being a place where the regular rules are suspended. ...You don't need to know where the kobolds poop for a dungeon to be compelling and powerful. And chances are, the more real you make it, the more boring the dungeon will be, because every interesting, dramatic thing you might want to do has to pass an arbitrary "realism" test...
It isn't about compelling and powerful. It is abount being sensical. If the dungeon makes sense, you tend to try to make sense out of the elements you see. If it is random and doesn't make sense, there is no reason to try. That takes away a powerful tool for storybuilding, and a significant element of the game.
And if you think that details in a story make it boring, you're overlooking a lot of fiction from the past several centuries that contradicts the theory. There are so many positive elements of the game and storytelling in general that are reinforced by having a world that makes sense, including suspension of disbelief.
Yes, you can run a game where you throw random stuff together and players look at only the short term issue of what is right in front of them - and that can be a blast. However, there is a huge benefit to using tools that support long term storytelling more comprehensively.
So, there's a right way to play?
Yes. The one that is most fun for you and your players.
That being said, I'm describing what benefits you get from having a dungeon that makes sense. I am not saying you have to play this way or I'm taking away your dice. I'm saying that having your world make sense provides you with a very strong tool.
There are costs to it as well - the DM has to put in the time to think things through, and regardless of how good you are, you're going to overlook some things which leave you with a need to patch over the accidental error. However, there is a huge benefit to having a world in which the players have reason to consider the things around their PCs that do not appear to make sense at first. Do the benefits exceed the costs? You have to anaswer that question for yourself - there is a considerable benefit and you have to figure out how big of a cost you consider the time it takes to think things through and learn how to build sensical environments.
There are a lot of opinions here…perfectly valid opinions, mind you…presented as objective facts.
This may be your experience, but it is by no means universally shared.
The view is not universally shared, but the underlying logic is not loose opinion. A lot of people do not know how a rainbow 'works', but that doesn't change whether you'll see one or not.
I've played with a lot of DMs, and I've run for a lot of players. When the world makes sense, the players strongly tend to expect it to make sense. When it doesn't make sense, players do not look for it to make sense in the same way. If you want to label that as an opinion, you can do so - but it is based upon a lot of factual observations over decades of play. Experience, not opinion, backs it up.
There are, of course, exceptions. Some players don't pay attention to the world at all, regardless of whether it makes sense or not. If that is your entire group, then you won't reap the rewards without some effort. And other players work really hard to make sense out of a world that just dosn't make sense (which is usually frustrating for the player in question).
However, the strong majority of players, and groups as a whole, tend to strongly fall into the trends I described: When the world makes sense, they try to make sense of the things they see. If it doesn't make sense, they don't try to find the sense in it.
Why is this such a powerful tool? When something doesn't make sense, and that is unusual, then it gives a reason to investigate and further the storyline in that direction. It gives the DM a tool to develop cascading continuity. It is a tool for building story without