The monster that kills you grabs your whole inventory and runs.
When a hostile mob kills you, it takes everything you were carrying, armor included. It gets your name ("Steve's Thief"), glows so you can spot it, gets speed and fire resistance and runs away from every player. Kill it and your items drop where it dies.
Only walking hostile mobs steal. Creepers, the Warden and the Wither never do. The thief never despawns and keeps your items through server restarts. Nothing changes if keepInventory is on.
Server-side only: install it on the server (or in single player), clients don't need it. No dependencies besides Fabric Loader, Fabric API is not required.
Heads up: if the thief falls into the void, your items fall with it. Lava is harmless to it, so lava does not burn your loot.
Minecraft 1.21 to 1.21.1, Fabric. MIT licensed.