On a kinda basic level, hdr records brightness.
A normal video might record the levels of red, green and blue per pixel, hdr adds brightness information. If you play a hdr video on a hdr display, the bright parts will be physically brighter and the dark bits physically darker. This also stops bright parts of the image turning pure white or pure black, it allows more detail to be displayed. Hopefully thats a decent explanation of the basics, the technical bits I know better.
The technical bits. By default, samsung hdr saves hdr data in a kinda spare area of the file. If a non hdr device tries to play it, it plays as a normal video. If a hdr device tries to play it, it will notice the extra data and show a hdr image. It's decent quality and backwards compatible with normal devices. Should be safe to leave on.
There is also a kinda hidden option to make it use the hdr10 format. This is a more fancy way of storing hdr data that saves even more image data, allowing a higher quality hdr image. Though if you try to play this video on a normal non hdr device, it might fail to play or have issues. So it looks better but doesn't work on all devices.
Kinda fun fact, if you have/enable "super hdr" in advanced settings, pictures you take will be displayed in hdr if you view them with the gallery app. All pictures you take have hdr automatically enabled using the first technical method I mentioned, the compatible one.
Kinda final note, the majority of modern phones support hdr, any Samsung s series from the past 10 years do