On Earth, most of the warmth that you feel comes from air around you – if you go into a room, and turn all the lights off, does it suddenly get really cold? The air itself is mostly warmed by ‘conduction’ from the Earth’s surface, which itself is mostly warmed by the Sun (there will be a smaller contribution to the air temperature from the Sun, but we can pretty much ignore that here). Therefore, as you get higher, the temperature of the air decreases.
In space, there is no air, so there is no layer of air around you to carry the warmth from the Sun to your body or to insulate you from losing heat yourself (you would also suffocate pretty quickly…)! Whilst there is a small increase in the amount of light you receive from the Sun if you go into space, it’s not nearly enough to offset the lack of air. I don’t know how close you would have to get to the Sun for it to ‘feel’ like you were on the surface of the Earth temperature wise – you could do the maths, but I can’t imagine it being a very pleasant experiment!
I’ve probably missed some of the points for this that a proper physicist might be able to clarify (I’m a chemist..), but I hope this answers your question 🙂
Hi milla123 – that’s a really great question. The main reason is that there isn’t very much of anything out in space, so there’s not enough material around to absorb the energy from the sun, and heat up. Of course, as you get closer to a star, you’ll be getting more energy from it, so space will get warmer as you get close to a star. If you managed to get very close, you’d be heading towards 6000 degrees C at the surface of our Sun!!
However, Earth is hotter than normal space at the same distance away from the sun because of all the matter that can absorb the energy from the sun. We’re also lucky on Earth that we have lots of molecules in our atmosphere which trap some of the sun’s energy, and heat up the surface of the earth (this is the greenhouse effect).