Updated:

The basic form

GoalJavaBedrock
Kill yourself/kill/kill
Clear dropped items/kill @e[type=minecraft:item]/kill @e[type=item]
Remove nearby zombies/kill @e[type=minecraft:zombie,distance=..50]/kill @e[type=zombie,r=50]

/kill with no target kills the player who runs it. It works in Creative mode too.

Do not use /kill @e on its own

@e means every entity in loaded chunks. That includes armor stands, item frames, paintings, minecarts, boats, named pets and villagers. Always narrow the selector with type=, distance= or a tag.

SelectorRemoves
@e[type=minecraft:experience_orb]XP orbs
@e[type=minecraft:arrow]Arrows stuck in the ground
@e[tag=boss]Mobs you tagged earlier
@e[type=!minecraft:player,distance=..20]Everything except players within 20 blocks (still includes frames and stands)

Drops and death messages

Mobs killed with /kill drop their loot and XP like a normal death, and the death message appears in chat. Players drop their inventory unless keep inventory is on. To clear the drops afterwards, run /kill @e[type=minecraft:item] as well.

Automatic lag cleaner

In a repeating command block, this removes items that have been lying on the ground for a while (Java):

/kill @e[type=minecraft:item,nbt={Age:5000s}]

Items despawn at Age 6000 (five minutes), so this clears them shortly before. It has to run every tick, because it matches Age 5000 exactly and an item passes that value only once. NBT checks are slow on large servers. A lighter option is a plain /kill @e[type=minecraft:item] every few minutes from a scheduled function, with a /say warning a few seconds before.

Common problems

Check your command

The Command Error Doctor checks common syntax mistakes in your browser.