The load and weight of the lower leg produce a clockwise torque about the knee. The lower leg will rotate in a clockwise direction.
If the hamstring muscle at the back of the upper leg contracts with a strong force, it produces an anticlockwise torque that holds the leg up.