Im gonna go out on a limb here.
I think its because like all mammals we are desdended from small burrowing incectovores like hedghogs, shrews, and moles.
These animals tend to be nocturnal even today.
We retain much of the wiring of these animals.
The back of our knees would have been the posterior of the back legs of all of our four footed mammal ancestors.
If the animal is a small burrowing nocternal animal and its sleep clocks tells it that "its day time- so its time for bedy bye" the animal will procede to retreat from the world by burrowing into the ground. But if its back limbs dectect light it knows it must keep on burrowing deeper because its posterior is still exposed. Only when its rear limb light sensors detect only darkness does it know to stop digging because its now safe to sleep.
Actually its a pretty good system because it frees the animal from having to turn around and look over its shoulder with its eyes which is hard to do in a narrow tunnel. It can just keep tunneling.
Our ancestors broke ranks with the other mammals and took to the trees and became diurnal primates early on, 60 million years later we learned to stand upright on two legs and can no longer burrow very well, but we retain these rear limb light sensors. These are still wired into our nervous systems in a way that influences our sleep cycle.