its some miracle of gravity really, it orbits in a circle at this lagrange point which basically keeps it on the dark side of the earth as the earth orbits around the sun. It's mad really, there's various lagrange points, you pop an object there and it'll stay the same distance from the earth and sun.
To expand on that, The Lagrange points are the gravity balance between the sun, the Earth, and the moon. There are five of them. If an object stays exactly at one of these points, the superposition of the pull forces of all three bodies is zero. But since you can't put an object's center of mass at an exact point, the spacecraft has to orbit the Lagrange point. Two of the points are of no interest for space work because they are unstable; a tiny deviation will force an object away. The other three (L1, L2, L3) are stable in one plane (a deviation causes an orbit like a satellite), unstable in the other (will push spacecraft axially away if drifted). L3 is behind the sun, and unless we want to see the sun only and not being able to communicate with the spacecraft, why go there? (That's where the aliens must hide!
) L1 is between the sun and Earth, and that's where solar observatories are placed in orbit. The Genesis spacecraft went there too. The L2 is on the opposite side, always in Earth's shadow, so it's perfect for observation of the rest of the universe. Once the spacecraft enters orbit there, it will be kept orbiting in the stable plane (no need for fuel for orbit correction as there is no atmospheric drag), and the corrections will be done for compensating for the unstable axial drift.