Keep inventory after death
Turn on keepInventory so you don't lose your items and XP when you die.
Commands
/gamerule keepInventory true Turns on keeping your inventory after death
/gamerule keepInventory false Turns off keeping your inventory (the default)
How it works
The keepInventory game rule is one of the most popular gameplay tweaks in Minecraft. By default, when you die you lose every item in your inventory and your experience points: the items stay on the ground for 5 minutes and then despawn. The /gamerule keepInventory true command changes that: after you die, you respawn with your full inventory and all your XP. It's especially handy in single player, on servers with friends, or whenever losing hours of farming would be frustrating (for example, when you're exploring an End City with an elytra over the void). Many purists see keepInventory as a cheat, but on community servers it's the standard: it cuts down on frustration and encourages exploration. The /gamerule keepInventory false command restores the default behavior. Keep in mind that keepInventory doesn't protect you from /clear: that command still removes items from your inventory.
Practical tips
keepInventory also keeps your experience points, so you don't lose any XP when you die.
It doesn't protect you from the /clear command, which still removes items.
On servers, the setting is saved in the world file and survives a restart.
Many players use keepInventory on survival servers with friends.