Neurosurgical Focus has an excellent article on the development of stereotactic neurosurgery where an external frame is usually screwed into the skull and fixes the head in place to allow surgeons to precisely locate brain areas in a standard 3D space.
In modern stereotactic surgery, the system is usually used with an electronic tracking system that maps the surgeon’s instruments onto a previously acquired brain scan in real-time. The frame allows the brain scan and the actual brain to be precisely aligned.
This means the surgeon can, for example, place a depth electrode into a precise spot without having to physically see that area while still being confident that they’re in the right place.
The system is also used in research labs to ensure that, for instance, the brain is stimulated in precisely the right spot with magnetic pulses, using a technology called transcranial magnetic stimulation or TMS.
For example, if researchers wanted to see the effect of stimulating the auditory cortex they could run a listening experiment in an fMRI machine, see exactly where your auditory cortex is by mapping the activity on your brain scan, and then use a stereotactic system (e.g. this one) to guide the TMS machine to exactly this spot on your actual brain.
With all of its high-tech trappings, I never realised that the first human stereotactic system was created in 1918 with the system you can see in the picture.
The Neurosurgical Focus article looks at how the technology has developed from the original brass contraptions to the modern age of neurosurgery.
Link to Neurosurgical Focus on the history of stereotactic brain surgery.