this is a long story. One can get close to a solution for him/herself only.
In theory, for HRTF a lot of things about your head are measured and transformed into a format (HRTF, SOFA) that can be used when playing back “binaural” material. It will be a bit closer to reality compared to not using HRTF.
Physically, it is about the difference of arrival times of sound on your left and right ear. It is different if coming from left-top-front or from right-bottom-back. Just a few milli-seconds. Also the shape of you head (cheaks, hair, nose etc.) is influencing this by influencing certain frequency ranges a bit. On top goes, that your ears and brain (!) where trained over your whole life. The combination of physics and psycho-accustics makes each individual able to locate the direction of sound.
To measure HRTF as best as possible, it needs several hours to a coupleof days with expensive equipment in a lab. Cheaper solutions do it with self-made measuring equipment or just with a photo from the side of your head. Am by far not convinced, that the photo approach is any close to reality. To me it is more of a marketing trick.
Such HRTF can be used in certain plugins to fine-tune the listening experience.
I have tested more than half a doezen of such binaural plugins. With or without photo, free or paid, with or without HRTF usage etc. I downloaded more than a hundred HRTF data sets hoping that one will be close to my head. Finally, I found a plugin, where I (!) can locate sound with. It was without HRTF functionality. (am intentionally not naming them here)
I had a couple of people test my results. The interesting thing is, that some where overwhelmed, that they can locate sound with a head set on. “Do you still have the 7.1.4 speakers on?” And others said things like “… seems all to be behind me …” and so on.
To summarize: Every head is different. There is no one-fits-all HRTF. Cheap HRTF approaches are more of a spoof-yourself-approach. There is perhaps a works-somehow-binaural approach. If one finds a solution that works for him/her, it will very likely not work for all others, with a little luck for a few others.
What for sure remains is imagination and marketing.