You don’t understand cameras, do you? Well, a quick lesson then. In cameras (other than cell phone cameras), there’s a thing called aperture. When there’s a bright light the aperture has to be small, to let less light in, so you can photograph something like the Earth. This avoids overexposure of the bright objects in your photo. In space, this blacks out the stars.
However, if like the Hubble Telescope, you just look away from Earth at the stars, you see a whole lot more of them than we can see here on Earth.
Here’s a photo taken of the Hubble Telescope from the point of view of the Space Shuttle Discovery. Notice, because the Earth is so bright, we don’t see any stars.
On the other hand, since the Hubble Telescope points away from the bright light source coming from Earth, we can capture images like these.