Space actually doesn’t have a temperature! Temperature is how fast particles move. The faster particles move, the higher the temperature. Since space doesn’t have particles that move around, it technically has no defined temperature! The temperatures that we are given of space are just determined by the probability of the temperature if there were particles in space.