How to keep inventory in Minecraft

One of the most annoying things faced by a Minecraft player would be losing all the articles collected by them every time they die....