When you change the attribute minecraft:generic.max_health it alwys resets to 20 after respawning.
How to reproduce:
1. Change the attribute to anything that you want. Rub for example this command: /attribute @s minecraft:generic.max_health base set 6
2. Die
Your max health will be 20 again.
I noticed I accidentally duplicated MC-179940