The head swaying which can also be the whole forequarters swaying is a rat that is attempting to focus on a far object. Pink and ruby-eyed rats have much worse vision and you will see this the most with them. They often do this faster when nervous, understandably since they have such horrible vision.
Depth perception using motion parallax: However, there are many other ways to perceive depth besides binocular vision (e.g. image displacement, motion parallax, and loom). Motion parallax is one of these non-binocular methods of perceiving depth. When one moves one's head from side to side, objects seem to change position relative to each other. Close objects seem to move more than objects that are far away. This is called relative motion parallax, and the brain uses it to calculate relative distance between objects.
And if you are curious, here's an estimation of what our rat actually sees...poor pinkeyed rats!!