Someone correct me if I’m missing some nuance here, but heat doesn’t get transferred directly through space because heat is vibrating molecules and space is a vacuum. The sun radiates (speed O’ light). A lot of that radiation just reflects off the earth (or we wouldn’t be able to see it), but a lot of it gets absorbed. THAT’s when it’s converted into heat energy. It’s also why the greenhouse effect is a global phenomena: light energy comes in across the vacuum relatively easily, turns to heat on Earth instead of being reflected, heat energy cannot escape as easily as light energy.
Infrared light is absorbed quite easily, producing heat, and the sun emits a lot of it. Of course, all photons that are absorbed and not reflected will produce thermal energy, and infrared radiation is commonly referred to as radiant heat. The other two heat transfer methods are conduction and convection, which requires a medium to transfer through.