This is a timely question, as I recently experienced a very exciting combat encounter, and so I’m full of ideas! Here are some suggestions:
Spicing Up Combat
1) Use a Variety of Enemy Types
This means several things. Obviously you want to be picking interesting opponents who will provide a challenge for your players. But don’t feel like you have to only limit yourself to creatures who are the same level as them. Taking down a big bad monster is fun, but so is one-shotting mooks. You can use different kinds of enemies within the same encounter to provide variety for your players and to force them to make more interesting tactical decisions.
2) Give them a Goal Beyond Just Killing
Maybe they need to rescue hostages or retrieve an item from the enemy. Maybe they need to defend a location. Maybe they need to capture an opponent. Maybe they need to gain some intelligence. Maybe they need to be stealthy. Maybe they need to make as big a distraction as possible. Maybe they need battle the elements or some sort of natural disaster while they battle with their foes as well. Maybe they need race against the clock. Maybe they need to make a daring escape as they fight for their lives.
Give them something to do besides just chipping away at each other’s health and you’ll force your players to use both their brains and their character’s other skills.
You can make your encounters unforgettable by engaging with your setting. If your players are in a dungeon with all sorts of traps and hazards, have their opponents actively make use of those traps in the middle of battle. If your players are in a vehicle such as a ship, consider all the problems that could occur (missed swing puts a hole in the hull, a fire spell sets the vehicle ablaze, the motion of the vehicle forces PCs to roll checks to stay in control, etc.). If they’re in a jungle, have them attacked by enemies in the treetops who can use vines to swing from tree to tree. If they’re in a ruin, have the battle possibly affect the structural integrity of the building. Maybe they’re in a technological setting and punching a hole in the wall leads to venting plasma or oxygen. Maybe rough terrain forces them to be careful about where and how they move.
Don’t just give them living opponents - have your players fighting the world itself!
4) Make Your Players Move
Nothing gets stale faster than a combat encounter where they just stand around exchanging blows. Force them to move! There are many ways you can use the environment to accomplish this (see number 2). You can also accomplish this by having the enemies move around. Have enemies attacking from multiple elevations (from the air, from rooftops, from below, etc). Have enemies use flanking tactics.
If you find that you’re reluctant to have enemies move because you’re afraid of players getting attacks of opportunity, consider ways to mitigate that. Also consider: is it better to have a long, boring battle, or a short interesting one?
5) Give Your Players Toys
When all you have is a hammer, your problems all start to look like nails. Give your players interesting loot that isn’t weapons or armor and see what they do with it. You’d be surprised what they might try with an immovable rod or a tanglefoot bag or a decanter of endless water. And if they come up with an idea to use their gear that isn’t necessarily spelled out in the mechanics? Let them do it anyway, if it’s interesting. This is why they’re playing a tabletop RPG instead of a video game or a board game. You as the DM can roll with the punches and let anything happen. Use that!
6) Encourage and Reward Creativity
To encourage your players to be creative, you can use NPCs to model the types of things you’d like to see. If you want to see more interesting tactics, have their enemies use interesting tactics. If you want them to role-play more during combat, have their opponents emoting and using more dialogue.
More importantly, reward them for being creative. If your players spend time preparing or coming up with a plan, let it work - to an extent. Sometimes as a DM, your instinct is to always think of ways to oppose them. For example, if they plan to sneak in somewhere using Invisibility, you may think to yourself “Okay! I’ll give their opponents guard animals with a strong sense of smell so that they won’t be able to sneak.” But that just makes your players feel disempowered and like planning is a waste of time. Instead, give them the satisfaction of success before throwing other unexpected wrenches in their plans to keep things interesting.
Hope some of this was helpful. Thanks for the question and good luck with your campaign!