The anvil is primarily used to repair tools, armor, and weapons, which it can do without stripping their enchantments, unlike the grindstone and crafting table.
Anvil mechanics - Minecraft Wiki - Fandom
This summary was compiled by our editorial team from publicly available information for quick reading. For full details, refer to original reporting where available.