For our spine. The pillows help support our head and neck. When I was younger I could sleep without a pillow and not much damage was done, but now that I have injured disks in my neck, if I sleep without a pillow 9 times out of 10 I’ll be in a lot of pain by morning, and risk the pain lasting for days.
Even without an already existing injury, no pillow means more risk of getting a pinched nerve or some sort of crick in your neck. Lay on your side, and put your head down on the mattress, one side of your neck is kind of hyperextended, because your shoulder lifts your body away from the mattress. So, it partly depends on the position you sleep in.
Also, people with GERD and other digestive problems sometimes do better if their head is elevated when they sleep.