This seems pretty widely done if not universal in Western society.
ISTM that this makes a lot of sense if sleeping on one’s side, due to the angle of the shoulder to neck. I wonder if there are other societies in which people sleep on their sides without pillows, and if so, how they deal with it.
Conversely, in the case of people sleeping on their backs, it’s hard to see a rationale for it. And I suspect it may even be damaging, in that it would get people accustomed to having their necks leaning forward. I can understand doing it once accustomed to it, but why people should get accustomed to it is harder to figure. Perhaps people lie in bed watching TV and the pillow makes it easier to see the screen and thus naturally sleep this way as well, which raises the question of whether this habit predates screens. Perhaps reading in bed is similar. Here too, I wonder what other cultures do in this regard.