Sun is the most important source for life on Earth which gives sunlight and heat on Earth. But I was wondering like how does the heat of Sun come on Earth when there is no medium out there in space?
You probably are under the misconception that heat travels only via molecular interactions. (i.e, heat transfer by conduction, which needs a medium of sorts). Heat also transfers by radiation, which the sun is an enormous source of. Electromagnetic radiation does not need a 'medium' to travel through. All types of electromagnetic radiation carry energy, which can be transferred to other bodies when this radiation interacts with them. The continuous stream of photons from the sun is what transfers its 'heat' to us.
The heat 'comes' as electromagnetic radiation, that is light. Light from the sun is electromagnetic radiation, that is a wave having energy and momentum or a very big amount of quantum particles, photons, that have energy and momentum. The interaction of this electromagnetic interaction is what heats the earth.
Hope this helps.
The heat from Sun, comes in the form of radiation. To be specific, the infrared part of the EM light is responsible for heating. Infrared frequency is closest to the resonant frequency of most molecules. Thus, when these molecules absorb the infrared radiation i.e. the molecules' electron clouds oscillate at the infrared frequency, there's resonance, which causes the vibration amplitudes to increase appreciably, leading to generation of heat. Note that I assume that you know that Electromagnetic Waves (EM Waves) do not need a medium to travel.