In Moments of Building Tension
Whilst it may be better to abstract the damage as User Kyyshack said in a comment:
If they roll an attack, what will players do if they don't get through in the first hit? Nothing has really changed so they'll just hit the door again. And Again. And Again. Until the door is broken. That's super boring and wastes time. It's much better to abstract that boring time away behind a single roll against a DC that will answer your question of "Do they break through quickly enough to catch the monsters off guard?"
Using the rules for Object AC and Hit Points could be useful to help build tension. Rather than having the PC’s roll over and over again, you could have monsters roll to see if they damage a door the PC’s are on the other side of. Seeing creatures claw through a door or ripping boards off it would create more tension than if they rolled a nat 20 and broke it down in a single turn. The former option might allow players more time to react to the issue and respond to it, such as by barricading the door, escaping, preparing an ambush, etc.
Additionally, having rickety old damaged doors or furniture can help to establish a theme. If players find a door that has already been damaged, they may want to investigate what caused it, and if that thing is still around. For example, if they found a door with a large axe wound in the middle of it like something out The Shining, players may wonder who was trying to get into this room, and why? Or, if they stumbled upon a door with a dozen puncture wounds in it like it was repeatedly stabbed by a dagger, they may investigate the cause - or not, but they’ll learn pretty quickly what caused those holes when they get hit in the back of the head by a falling flail trap.
Thanks to user Jared Posch for highlighting the idea of accessibility in their comment:
I would look at the accessibility of the lock, aka, can the players actually attack the lock. A door locked with a wooden beam would mean the beam is behind the door, so unless a player can accurately swing his sword down the middle, I'd say they don't do damage
Rather than players having to completely open a door (such as by destroying it completely or by bashing through the door with a DC Strength check), players might partially damage a door.
For example, players might cut a hole around the locking mechanism to open a door, leaving it damaged but mostly intact - perhaps only removing 1 or 2 HP from the door.
Or, players may cut a hole in the door, creating an opening large enough for a Small creature to go through (or a Medium sized creature if they squeeze through the hole). This could be useful if they know they are being chased by Large creatures as it would slow them down. Alternatively, Small creatures like Kobolds might make holes in locked doors as it would slow down Medium sized creatures, hinger Large creatures but would not affect Small creatures like themselves (or they could make Tiny holes so they could squeeze through but larger creatures wouldn’t be able to).
Players may even put a hole in the door to gain access to the lock or door bar on the other side, allowing the door to be easily unlocked.
Treat the door as though it was made up of smaller objects. So, whilst you may need to remove 18 HP to destroy a Medium sized resilient door completely, you may only take off 5 HP to put a Tiny hole in it or 10 to put a Small hole in it.
User guildsbounty helpfully pointed out:
Perhaps worth noting: some published adventures explicitly call out that a properly fortified door cannot be kicked in with a Strength Check, and must instead be destroyed by attacking it. The most recent example being in Ghosts of Saltmarsh.
Having this clear distinction for Reinforced doors could be quite a useful tool. It may force players to make a decision between completely breaking this door, which would be very noisy and may take a long while, or finding another way through it. Here is what the Ghosts of Saltmarsh says about reinforced doors, page 157:
It takes a character 1 hour to gather the required materials and reinforce one door. The time is cut in half if another character helps.
A reinforced door cannot be broken through with a Strength check, but must be battered down (AC 15, 30 hit points, immunity to poison and psychic damage)
Note that this rule is assuming the door is made out of wood, is being reinforced with wooden planks and nails and these materials are readily available.
A possible way to calculate the health of a reinforced door is to add the health of the reinforcing objects to it and use the highest AC. For example, a Medium Resilient wood door (AC 15, HP 20) is being reinforced with Small Resilient planks of wood (AC 15, HP 10). The highest AC is 15 so the door has an AC of 15, 20 HP plus 10 HP equals 30 HP, giving us AC 15, HP 30 for the reinforced door in question. If we were using steel bars to reinforce the door instead, as they have an AC of 19, we would instead have AC 19, HP 30 for the reinforced door.
So then, one possible situation where you would use AC and HP over a DC check is when a door has been reinforced, either by the players or by the inhabitants of a dungeon.
Hitting Creatures Behind Cover
This follows up from the idea of partial opening. I got a bit carried away but this highlights how object AC could be used in a completely different way than how a DC check is used:
A creature can use any suitably large object as cover from an attack. A creature gains bonuses to their AC and Dexterity saving throws depending on the level of cover. A creature in total cover gains the bonus of it not being able to be targeted directly.
If, for the purposes of an attack, we treat the door as a creature, we can use the Cleave Through Creatures optional rule in the DMG page 272:
When a melee attack reduces an undamaged creature to 0 hit points, any excess damage from that attack might carry over to another creature nearby. The attacker targets another creature within reach and, if the original attack roll can hit it, applies any remaining damage to it
So, using the example of a door, its a Medium sized resilient object made of wood, so it has 15 AC and 18 HP. However, we are targeting a Tiny section of it, so the AC is 15 and the HP is only 5. The attacker rolls a 16 and deals 7 damage, this hits the Tiny section of the door and reduces it to 0 HP. As we are using the Cleave Through Creatures rule, the attacker still has 2 damage left over which can be used to hit a creature within range (such as one who was standing right behind the door).
Because the weapon has now gone through the cover, the creature is no longer in cover for the purpose of this attack - just to be clear, any bonuses for cover (such as increased AC, better Dex Saving Throws or being untargetable) the creature had are being ignored by this attack.
If the 16 rolled by the attacker earlier to hit the door is enough to hit the creature behind the door (without any bonuses from cover) they will take the remaining 2 damage. If the creature had an AC of 17 though they would manage to avoid any damage.
This rule would make more sense when applied against a creature behind a fragile material, such as glass. (Due to glass only having an AC of 13 and being fragile, a Tiny section of that might only have 2 HP, meaning more damage is transferred to the target). It also makes sense thematically, Rules as Written would say standing behind a glass window or a curtain or even pulling the bedsheets over your head would count as cover, they might even count as Total cover, preventing the creature from being targetted. However, by using the Cleave Through Creatures rule in this way, we can make things more realistic “that window will not stop this arrow going through”, “those curtains or those bedsheets aren’t going to stop my sword from stabbing you”.