Sunlight hits gas molecules in the atmosphere and its wavelengths scatter in different ways. That makes the sky appear blue during the day, while at sunrise and sunset red light dominates.