In Vanilla (Plain, un-modded, without cheats enabled) Minecraft there is no command to save your items.
When you die you drop everything that you are carrying at the time of death. The items stay on the ground for about 5 minutes, or if the chunk has been unloaded forever.
To set your spawn you need to sleep in a bed. Generally it's a good idea to wait a few seconds before getting out.
There are a couple conditions you may need to follow to have it set your spawn correctly:
- The bed is not touching walls.
- There is only regular blocks surrounding the bed. No glowstone, half-steps, glass, etc.
- There is enough space above, and around the bed to spawn.
If a player's bed is destroyed or the bed is surrounded by solid blocks and the player dies when the player had set his spawnpoint there, a message is displayed saying Your home bed was missing or obstructed, and the player will respawn at the original spawn point. With this in mind, the player should know how to navigate to their base with the bed from the original spawn point, or keep their base near the original spawn point.
Above from Minecraft Wiki: Gamepedia.