Minecraft wiki entry for Anvil_mechanics, associated text: Renaming any item, including normal blocks. Any renamed block/item's name will be italic and lose their text color. Note that most blocks lose the rename when placed, except some containers, which shows the name if opened (naming a chest "container" will cause the chest name to turn into "container" if placed and opened).
Repairing any gear with units of its material. For example, iron ingots can be used to repair iron tools and armor. Acceptable items for repair have the material to use in their default name, except for chainmail (repaired with iron ingots), turtle shells (repaired with scutes), and elytra (repaired with phantom membranes). Golden, wooden, diamond, netherite, leather and iron tools/weapons/armor can be repaired using an anvil, but fishing rods, bows, and crossbows cannot be repaired using sticks, despite being made from sticks.
Combining two items of the same kind and material that have durability, e.g. iron pickaxes, bows, shears, etc. The durabilities combine similar to using a crafting table, and the enchantments are combined following rules detailed below.
Combining a tool with an enchanted book to add the book's enchantment to the tool. This costs much less than combining enchantments from two similar items, and can give enchantments to items that they could not get at an enchanting table.
Damaging any players or mobs who happen to walk under or be under the anvil while it is falling. This causes the anvil to degrade one level and deal 2 HP damage for each block fallen after the first block to the mob/player who were crushed. A maximum of 40 HP damage can be dealt by a falling anvil, no matter how high the anvil falls. Other than crushing mobs/players, falling anvils can also crush any dropped items and destroy them.