The role of the DM in all this is to act as a referee. Which means when the party easily defeats a level appropriate encounter, their reward for this is whatever XP and loot comes from that for little effort. It also means that when adventurers are not up to the task of adventuring, bad things tend to happen to them. Both of these are very important, as without effective and ineffective choices having corresponding consequences, there is simply no correlation between cause and effect. You end up with the Three Stooges running around because actually thinking and planning things is punished.
I have to object to this. The referee concept presumes the game is firstly, a contest, a challenge, and that does not universally hold true. In a roleplaying game, the loot and experience obtained from a challenge is not a reward, but a progression of character, with characters evolving as they deal with conflict and issues.
This in turn is an extension of playability. The 'given' challenge of any encounter is only an approximate value, and calculating it objectively is a lost cause. So in the role of the game, difficulty's purpose is:
-Entertainment. Through overcoming the challenge, entertainment is obtained. This purpose is poorly served should a weaker party get destroyed by an encounter. It is also somewhat similarly ill done to have the challenge being too trivial. Therefore, difficulty should modify based on party capabilities.
You do not throw optimized casting encounters against the party of monks performing a pilgrimage, or use scry and die tactics against the players doing an all-rogue band of thieves. Cause and effect do not come into this(yet), particularly when from the player perspective, they do not know a future encounter has been modified(because the encounter does not exist until they play it)
-Character evolution. Through challenges, you alter characters. In D&D terms, this is XP, wealth and semi-permanent effects on the character. This is distinct from encounter challenge. There is a target rate of growth for each game group, and basing evolution on the purported challenge difficulty sets up for trouble.
A hypercompetent party blows through encounters beefed up to accommodate their ability, and through this, gains even more competence, and widens the gap even further. In D&D this only ever aggravates the problem, as the degree of rocket tag rises, an encounter they should be able to blow through is also an encounter that can pulverise them with about the same difficulty. This rate should be based on what the group needs, not on challenge, it is also why one of the more common house rules is that characters level up when appropriate, and why 'trivial' encounters do not generally warrant experience.
-Story evolution. One common Bad GM story source, when they raise the value of their story over the value of providing appropriate challenge and character evolution). Encounters have a role in the setting, story or plot to maintain believability and also plot based enjoyment. Pacing this element with the previous can be a problematic area, but essentially, the challenge needs to fit the story and vice versa. When your players can only be feasibly challenged by dragons, demons and casters, then you have to either rein them back so the story can continue working(such as, after an unexpected source of wealth like looted adamantine dungeon furnishings), or you have to move them in the story to another.
-Gratification. When you combine the above, this is what you get. Players are satisfied with the challenge dealt, their growth rate is just right(too fast, and you gain new abilities before you settle into old ones, too slow and you feel static) and it all fits in with the story as given. Different players might enjoy different aspects, but few would do so to the complete detriment of the other areas.
Treating the GM as the referee is far underselling his role in the encounter. The encounter is not a static construct, it lives and evolves based on the group's needs.