When I was running my players through Rescue at Rivenroar, one thing that struck me as I did my session and campaign planning was the sheer number of encounters to be found in the adventure. Almost every room had a combat encounter and it turned into a grinder of predictable combat. My experience playing other adventures like Keep on the Shadowfell and Thunderspire Labyrinth were similar. Even more recent products and adventures have a lot of combats. Although 4e combat is fun and it's far easier to write an adventure with combat than it is to write one with roleplaying (because it's hard to predict how players will roleplay and what they will do), it can make for a dull adventure if not done well. I always knew that myself, but my time spent with Rivenroar reinforced the lesson like few other things could. So I want to share what I think about this aspect of encounter design.
Make Every Encounter Mean Something
One of the major problems a lot of modules have is that they have combat encounters that don't really mean anything. Either by themselves or in the context in which they're presented. Combat for the sake of combat is rarely a good idea. For that matter, skill challenges for the sake of skill challenges are no better. The better way to approach encounters is to have a point to them. Encounters should always add to the adventure in some way. It may be thematic (establishing an undead area by PCs running into some), narrative (the PCs are attacked by assassins from the Big Bad), strategic (the orc raiders have scouts out on patrol), environmental (the PCs have triggered an ancient magical defense system), reactionary (the kobold who fled a fight has set off alarms in the warren), climactic (the players face off with the mastermind of an evil plot), or whatever.
Ask yourself why the players might have this particular encounter. Ask yourself "why" as many times as you need to until you either have a good reason or no reason at all. If you can't come up with a good solid reason for it, you should reconsider having that encounter right at that point. And honestly? Sometimes the reason might very well be "Because it's a cool encounter and my players will like it." As long as everybody is having fun, you're doing it right.
Make Every Encounter Unique
Sometimes even adventures with encounters that answer the question of "why" still end up feeling flat, dull, or boring. One possible pitfall is using too many of the same sorts of monsters. This can actually be a big problem, especially for someone like me who likes a strong theme to an adventure. You can very quickly run out of new monsters of the appropriate type to throw at the players and surprise them. Sometimes you want to broaden your theme or scope of the adventure to give yourself some leeway. To use my own game as an example, if I could have I probably would have just used goblins and hobgoblins for most of Rivenroar. But I would have found myself using the same enemies over and over. So I added in a reason to have undead around and I was able to better create encounters that all felt different from one another. Adding a different sort of monster from the ones that PCs have been fighting can be a breath of fresh air.
Another way to make encounters unique is the environment. An encounter can be drastically different in feel and result depending on where you place it. Add environmental effects like rain to cause penalties for ranged attacks. Let the terrain shape the battle by placing fields of boulders and rocks which count as difficult terrain. Put incentives and objectives like a magic circle which gives +1 to attack for creatures standing in it. Add in dangerous effects like a fountain which spews necrotic acid at random intervals. Add shelves that players can push over onto bad guys or to use as cover. If you make an encounter more than a simple straight up fight to the death, they're more likely to enjoy it.
Make Every Encounter Memorable
This can be both the easiest and hardest thing to do when making and playing encounters. Players should walk home from the game thinking about how fun, cool, or interesting it was. You want something they'll be talking about between each other for a while or that makes them want to go on a message board or Twitter to describe. Sometimes, making an encounter memorable can be nothing more than good roleplaying or description from the DM. Orcs who shout battlecries and taunts, mad necromancers who lecture and rant at the players, grim and silent assassins who use elaborate maneuvers and hand signals as they attack, feyborn creatures who laugh and sing as they draw blood, or whatever.
Altering the conditions of victory is another option to consider. If the players have to stop an evil ritual by destroying six magical idols while holding off mad cultists, that can be more fun than just going in to kill the cultists outright. Enemies who fight with hit and run attacks can leave the players excited to finally get the chance pin down and have it out with their tormentors. Encounters where players have to protect something can also be exciting and nerve-wracking. Put the players on the other side of the ritual example from earlier and have them defend a magical ritual from those disrupting it. Have the players fend off slavers trying to capture panicked townsfolk.
Throw the characters a curveball every once in a while, just to keep them on their toes and not take anything you present them for granted. A fight where high winds scream through the area, pushing people and knocking them prone every few rounds, can shake things up. Throw in an occasional fight in the air or under water where players have to think and act in 3D. Run an encounter where players are defending a town and have access to things like siege equipment or burning pitch but have to fend off enemies with ladders, ropes, and siege towers.
Are following these ideas guaranteed to get you awesome encounters every time? No. Sometimes even the best ideas and efforts will fall flat at the table. Sometimes what you thought was awesome, players will find boring. Sometimes your carefully crafted encounter will be undone in moments by bad DM rolls or good player rolls (or both). Sometimes either the DM or the players will be having an off night and end up with encounters that don't live up to their potential. However, I think that if you really try to incorporate these ideas into your adventures and encounter design, players and DMs alike are more likely to have a good time by eliminating flat or dull encounters that do little more to add to the adventure besides fill time and provide some experience and loot and replacing them with something which will hopefully be more interesting and engaging.