Why does nodding of the head signify Yes and shaking of the head No?

2 answers

From Google:

As to countries which practice the usual nod/shake arrangement, nodding likely originated as an informal bow. Bowing has since disappeared, but the humble nod remains. Shaking the head probably started as an exaggerated form of turning away from something undesirable.

More specifically, when a baby does not want to eat something, s/he moves his/her head from side to side to avoid the food. This is generalized into the no response.
Also, try "psychology".