When you look at anatomy books or software renderings, it looks like the nerves and muscles are loosely distributed around your neck. Like, there's plenty of space. The nerves in this picture are way out of the way of bones, joints and muscles!
But when you look at this cross section of the upper cervical spine, you can see the "Greater Occipital Nerve" is very tightly packed between the inferior oblique muscle and the vertebral column of C2. There's no space between.
And when you look at the sensory nerve distribution of the greater occipital nerve, you can see how nerve irritation there can cause a headache on the back of your head.
Also, any sensory information coming in from the top 3 neck nerve roots will merge and diverge with the signals from the V1, V2, and V3 segments of the trigeminal nucleus, right in the brainstem. It's all in the spinal tract of cranial nerve V.
Now look at this common injury. The inferior oblique muscle has been strained and bruised. It got pinched between the bones of C1 and C2. You can see bleeding on this slide. This soft tissue injury will cause pain at the base of your skull and probably headaches.
This is an injury of the articular surface between C2 and C1, in the upper neck. You can see bleeding around the nerve root at the "dorsal root ganglion." Plus, the synovial folds at both ends of the joint have become pinched and bruised. This is a very sensitive part of your neck, and can become very painful.
These ligament sprains and muscle strains are hard to localize in your own neck, so they can create a diffuse radiating pain, that can radiate to your head.
And when you have any kind of soft tissue injury like this, you need to make sure you heal with better function. Don't let it glue into place; make sure you keep proper movements in the joints and muscles, to stimulate the healing process. Chiropractic care helps with this, in the various stages of soft tissue healing.