It is a question of radiation emission - the temperature of the Sun's 'surface' is about 5500°C (according to NASA Earth Observatory), at that temperature, it emits radiation in the UV, visible and near infra red region - due to the fact that the hotter an object is, the smaller the wavelength radiation is emitted, as can be seen in the generalised image below (from NASA):
Note: the temperature of the Earth shown is an approximattion of its blackbody temperature, explained in the answer to the question What would be the temperature of earth if there was no atmosphere?.
Not all of this radiation reaches the top of Earth's atmosphere reaches the surface, a proportion is reflected off the atmosphere and some is absorbed by the atmosphere (as shown as the difference between the yellow and red in the diagram above) - but a good proportion reaches the Earth's surface.
But that is not the entire picture, we receive this 'shortwave' radiation from the Sun:
Which is also balanced by an equal amount of energy radiating into space as 'longwave' thermal infrared radiation:
(Both images from NASA Earth Observatory)
Which leads to a major point - we have an atmosphere and a natural 'greenhouse effect' due to the water vapour and carbon dioxide (and other components) that are seen in the above solar radiation spectrum diagram.
Some of the thermal infrared is absorbed by the atmosphere and re-radiated back to the surface. This radiation budget is shown below:
Something to consider, looking at the value the NASA has for the incoming radiation reaching the Earth's surface - 168 Wm-2 - imagine that being a 168 watt light globes for every square metre - that value increases markedly when the re-radiated thermal infrared is taken into account.
Also, please view the YouTube clip How the Sun Heats the Earth which is a handy verbal and diagrammatic explanation of the content of this answer.