1. Use the morale system
Not all creatures fight to the death. The optional morale system (Dungeon Master's Guide p.273) has opponents roll a DC 10 Wisdom save whenever surprised, reduced to half hit points, unable to harm the PCs at all, their leader is reduced to zero hit points, or half their allies are killed (see DMG p.273 for the exact rules on this).
A creature who fails his save flees. If they cannot flee, they surrender. Morale was a bigger deal in earlier editions of D&D, where powerful or mindless creatures might be fearless, but weak enemies often fled. It comes from D&D 's wargaming roots, but it's useful to wrap up the combat when it's clear to both sides that the PCs are going to win.
2. Use more weaker creatures
Don't necessarily use one big challenge rating appropriate creature with a lot of hit points. Lots of small, weak creatures, even if below the party's standard challenge rating, will go down quickly.
3. Roll ahead of turn
Have players roll attack and damage ahead of their turn. When it comes to their turn, if they rolled low and certainly missed, they can simply say "I missed" and move on. If they hit, they can immediately state the damage value.
4. Use average damage for monsters
Have monsters use the average damage value. This saves you having to roll and add, which take time.
5. Hurry your players
There's a system I don't like where players are literally given six seconds (the traditional length of a combat round in D&D) to take their turn, but I find this too harsh. However, you do want to encourage players to hurry. Consider how gameshow hosts pressure indecisive contestants to give an answer because everyone's aware that they're on the clock.
This is an important one, because, as you mentioned, there's a certain threshold where if players' turns take too long, the other players become distracted. Once you speed up by a certain amount, the group will stay in formation.
Something I've tried that you want to avoid is forcing players to do their weakest at-will attack as punishment for not deciding their action quickly enough. This is something people used in 4th edition and it typically had the result of dulling the party's damage output, which only caused combat to take longer.
6. Reconsider miniatures
Consider using miniatures if you don't, or consider not using miniatures if you do.
For some groups, miniatures make it easier to see at a glance what the combat situation is, and keep the players focused. This might benefit your group if players frequently stop to ask questions about where someone is relative to someone else. You might use paper printed minis stood on bases (a digital gametable works well in online play also) and simply write the creature's damage score on the mini so everyone can see the damage value.
For some groups, miniatures just slow the game down as tactical positioning just adds another layer of decisionmaking. If this is your group's problem, try playing without miniatures instead and see if that works for you.
7. Use passive initiative
An optional rule in the Dungeon Master's Guide involves taking 10 + Initiative modifier rather than rolling 1d20 + Initiative modifier. This saves a small amount of time at the beginning of combat and helps ensure everyone always knows the initiative order within the party, so no players are surprised when their turn comes up.
8. Take the DM's turns more quickly
As DM, make sure your save as much time on your own turn as possible. Roll multiple monster attacks at the same time, learn your monster stats and rules and spell descriptions ahead of time, make temporary rulings on the spot to save looking things up in books, and hurry in general.
9. Know your players
Between sessions, learn all the rules for things your players use: their spells, class abilities, options the next time they level up, and so on. While these things are the player's responsibility to know, learning them as DM saves you having to ask when a player inevitably forgets how a spell works.
10. Pay careful attention to what takes the most time
Only you and your group know for certain how they play. Take careful analysis of what exactly causes your group to take longer than necessary. Do you have one particularly slow player? Do your players spend a lot of time rolling or adding dice? Only you can get to the source of the "slow".
Conversely, watch online D&D streams and compare their gameplay to your own. Time their combat rounds, the GM's response times, each player's turn, and so on. What does your group waste time on that the streamers don't? If other groups get along fine whle being faster at certain game elements, this suggests there's room in those places for your group to catch up.
11. Offer one-shot ways to deal more damage
A solution used in 4th edition which may work here is to create environmental effects and terrain features which the player characters can use to deal more damage than their basic melee or ranged attack. These reward players for their ingenuity and willingness to take risks, provide interesting variation, and importantly increase damage output which ends the combat faster.
Examples include deep pits you can push opponents into, traps or defensive features you can force the opponents into, tables full of alchemical components you can flip onto an enemy,
12. Lower the enemies' AC
Use enemies with a lower armor class, or reduce their armor class by a point or two. This reduces the number of times your players miss, which increases their rate of damage output, which ends the combat faster.
13. Have monsters take risks
If your monsters are halfway dead and haven't fled (perhaps they pass their morale check), perhaps they are reckless or brave, and will take unnecessary risks, which will cause them to take more damage and end the combat faster.
Examples include pushing past player characters hoping to get a flanking position (provoking opportunity attacks), leaping from high places (injuring themselves in the process), throwing away their heavy shield to fight two-handed (switch to a two-handed weapon like a longspear, use a one-handed weapon two-handed for better damage, draw a dagger to two-weapon fight, etc), or a caster switching from safe ranged spells to melee spells.
14. Post the creatures' stats openly
Track everyone's initiative, and the creatures' hit points, status effects and AC, on a whiteboard. I've used a fridge magnet to track initiative.
This has several benefits: Players are always aware of the initiative order. Players never have to ask "which enemy is most badly damaged?", "Does 15 hit?" or "Which of the bugbears is on fire?"
You can even outsource the whiteboard to one of the players, freeing you to think about monster actions or tactics or other things.
15. Offer Advantage and Inspiration frequently
Give the players more ways to gain Advantage (terrain, situational bonuses, optional flanking rules, Inspiration, etc). This not only rewards ingenuity and makes combat more interesting, it makes PCs miss less often, and so combats end sooner.