It lets everyone know that this roll may behave different
The reason to declare a "Nat 20" is because some rules, both strict and optional, change based on rolling a 20 on a 20-sided dice. This is to differentiate from a "dirty 20", where a person rolls a d20 and after applying bonuses and penalties gets a total of 20.
For instance, with death saving throws, if the person rolls a 1 or a 20 on the die it counts as two failures or auto success and 1hp.
Similarly, when attacking, rolling a 1 or a 20 has special rules.
If the d20 roll for an attack is a 20, the attack hits regardless of any modifiers or the target's AC. This is called a critical hit...
This is different than rolling an 18 and getting a +2 proficiency bonus for a total of 20.
So it's important to note whether a 20 is natural or dirty.
DMs should also say it as a courtesy
A player will cheer when they get a Nat 20 as it can mean extra damage, gaining 1 HP and becoming conscious after death saving throw, etc. So the DM needs to take note/action appropriately.
But DMs should also say out loud when an NPC/creature rolls a Nat 20, as there are features that could negate the bonus.
One example is if a character is wearing adamantine armor:
This suit of armor is reinforced with adamantine, one of the hardest substances in existence. While you're wearing it, any critical hit against you becomes a normal hit.
This means that when the Big Bad rolls a Nat 20 against that character, they do not take double damage.
So it's best if the DM says something before rolling damage in case the character can change the outcome.
On the flip side, there are features that can alter bonuses/add penalties to a creature's roll.
Examples would be a College of Lore Bard's Cutting words or a Path of the Beast Barbarian's tail form of the beast. One applies a penalty and the other increases AC.
But if a Nat 20 always hits, then the character would be wasting their reaction so letting them know up front saves players from wasting those features.