Wow. That is something I had never stopped to consider. But I think I have the answer 🙂
The sun transfers its heat via electromagnetic radiation, and we named the modeled process “black body radiation.”
Space is a vaccuum, meaning that it has very little particles (bascially none) in a given volume. Heat is esentially particles vibrating more than they normally do and when they bash into something they transfer energy – this is how heat spreads in a very basic manner. So with no particles in space to vibrate or bash into to pass heat along space stays cold.
Earth however has lots of particles in our atmosphere and therefore the energy in light can be passed to the atmosphere and heat it up.
The amount of radiation received and absorbed depends on the material composition of the body and the cross-sectional area of the body perpendicular to the path of the radiation. As spacecraft travel to the inner solar system, the heat management becomes an immense problem. To counter the higher energy, the spacecraft are coated in reflective materials to deflect the heat and/or coated in materials that can absorb the heat, but not transfer the heat into the body of the spacecraft.
Even though it is cold between the Sun and Earth, if you put something there, it will heat up due to absorbing the radiation from the sun.
Like Tom said, it’s mainly because there is no matter to heat up, and it looks dark because we are looking at nothing for billions of miles. The things we see during the day are only light up because of reflections from the Sun’s rays.
The best way to understand this is thinking about the International Space Station. It orbits Earth 16 times a day. When it comes in between us and the Sun, it lights up very bright and captures the Sun’s rays by its solar panels to power it. When it is behind us (where the Sun can’t reach it) then its surface will be colder, but because it stores energy from the solar panels the Astronauts don’t get cold 🙂