Spatial audio (and by extension, binaural audio) has been an ongoing research project in a lot of different places over the last 10 or so years. The problems involved have been mostly theoretically solved, but Apple is the first to bring to market a consumer product that takes various Dolby multi-channel surround sound input types and outputs a true binaural stereo audio stream that varies with head (and screen) movement in 3d space.
Here's one place to start if you're interested in the ongoing theory/research: https://www.bbc.co.uk/rd/projects/binaural-broadcasting