The short answer is that it travels from the centre to the photosphere, where it escapes and propagates to the vauum of space to Earth. The trip from the centre is hard for light. Photons are very good at interacting with electrical charges (e.g electrons), and the plasma in the Sun is ionized, so there are many charges to go around! Photons are constantly stopped in their tracks by electrons and scaterred in random directions, so it takes them a long time to escape. Energy is transported from the core to the photosphere either by radiation or convection, depending on where you are in the Sun. Eventually though it does reach the photosphere, and from there it travels almost unimpeded to the Earth.