KeepInventory setting toggles off when changing difficulty from Peaceful to Normal or above on a world with Cheats Enabled
When playing on a world with cheats enabled, turning on KeepInventory then changing the difficulty to Normal or Hard turns KeepInventory off.
When playing on a world with cheats enabled, turning off KeepInventory then changing the difficulty for Easy or Peaceful turns KeepInventory on.
When playing on a world with cheats disabled, changing the difficulty form Hard or Normal to Easy or Peaceful does not turn on KeepInventory.