What's the point in building up a grand, terrifying enemy if they turn out not to be a threat to players? What is a boss without their minions? How do you turn world-ending narrative into character-ending fights? Let's see if we can break it down.
Feeling Threatened is Important
As a player, the most desperate, skin of your teeth fights tend to be the most memorable. This doesn't mean that as a DM you must always make every fight a close one, nor does it mean that a PC or two must die in every boss fight. What it does mean is establishing and delivering on stakes. The players should know, going into the fight, what the stakes are. Has the BBEG set up a system to kill their loved ones should they die? Are they setting off a potentially world-ending weapon? Are they trying to achieve unearned immortality? Establish stakes that the players care about and the players will feel threatened going into the fight.
Mind your Action Economy
It's the number one problem with big boss fights in 5th edition. A party wants to rest up and feel strong before they take on the bad guy, but if the the bad guy is just one guy then regardless of power level it's very difficult to beat the party. There's more than one answer to this, the most common and straightforward is to surround the boss with a dungeon of some kind that will chip away at spell slots or health or both. Another is to surround the boss with minions, to help balance out sheer number of attacks per side. But the one that really identifies a boss, and which I believe should be doled out more liberally, are legendary actions. But before I get on my soapbox about legendary actions, let's break down what a boss really is.
The Boss and You!
Any enemy can act as a boss so long as they present some kind of threat to the party. A boss maybe isn't even a combat encounter, they themselves could be weak but are simply presenting the party with traps or minions that are terrifying. A boss then, is not based on their CR or their alignment, but on their role in your narrative. The boss, which may apply to a whole campaign, a level, or even just a single dungeon; is your party's antagonist. In storytelling terms, that means it is the creature that is forcing your PCs to change. Change comes in many forms, but for a story to be dynamic and interesting, it's characters must change. Your players are playing the characters, but you play the arbiter of change: their antagonists. Or, in other words, the bosses.
How do I force Change?
What does this PC care about, and what would challenge that? Try taking an ideal or a bond or two of one of those categories, and threaten it. For instance, if a Paladin has the ideal that they must always help those less fortunate than themselves, but they're bonded to their wife, force them to choose between a group of peasants and their love. Either decision belongs solely to the PC, but will force them to reconcile either the loss of their ideal or their bond, and subsequent change. Change need not always be motivated by loss, sometimes it's about giving a PC exactly what they want at the least expected moment. Getting ready to kill a dragon for gold, but suddenly that dragon offers that PC the exact magic item they were seeking. What do they do now that their dreams are within reach, and do they go back on their word to slay the dragon? Take the things that your PCs care about, then dangle them in and out of reach until your players are forced to make concrete decisions. Then fight them.
And we're back
So, your players are set up to fight for the thing that they've made a concrete decision for, and they're up against that creature which has forced them to make that decision. How do you make that creature combat ready, regardless of what their actual stat block says? After all, for a low level party a simple Ogre can be a legitimate boss. So, how do you turn an otherwise ordinary creature into a boss, through gameplay (following narrative setup)? Legendary actions. Give any and all creatures that you consider to be a boss a few legendary actions, and suddenly combat becomes way more interesting. Be aware that when you're altering a stat block this will increase the power level of an enemy, but in turn 5e states that CR is based off of 8 to 12 combat encounters per long rest. In short, if the party is well or fully rested then legendary actions will level the playing field, if the party is low on health or spell slots it will tilt the odds drastically in favour of the boss. So if you're going to be giving the party an opportunity to rest and prepare for a known boss fight, then you can be confident that legendary actions are a safe bet. People will often also slap Legendary Resistances on with Legendary Actions, and I don't think that's a bad thing, but in terms of flavour it doesn't really add the same amount as Legendary Actions. You want a boss, during a fight, to convey two messages:
1. Hit me and I hit back
2. It takes all of you to even come close to equalling me
Many monsters can achieve some level of these messages naturally through multiattacks and high HP/AC, the beauty of a Legendary Action is that it becomes very clear very quickly. It also goes a long way to balancing the action economy, as previously mentioned, and lets you incorporate abilities that you may have attributed to this creature through narrative earlier in the story. It rounds out the boss as not only an agent of change, but a threat.
Bosses are important, and if you're going to go to great lengths to build any NPC, the bosses should be the ones you focus on most. Give them the tools to pick on what your characters care about in order to force concrete decisions, and when combat arises make them threatening and powerful. That way, every boss will be an interesting one.