When you type in the effect command for resistance 5 or higher, you take no damage from anything. However, once when you log out and log back in, the resistance effect doesn't work anymore and you start taking damage from anything that hurts you. The same thing happens for regeneration; you log out and back in. You will not heal faster
Hey there!
This looks to be a duplicate of MC-118857. Just to further inform you, this same idea affects all potion effects and not just resistance and regeneration. See the duplicated link for more details.