A photon travels, on average, a particular distance before being briefly absorbed and released by an atom, which scatters it in a new random direction. To travel from the sun’s core to the sun’s surface (696,000 kilometres) so it can escape into space, a photon needs to make a huge number of drunken jumps.
The calculation is a little tricky, but the conclusion is that a photon takes many thousands and many millions of years to drunkenly wander to the surface of the Sun. In a way, some of the light that reaches us today is energy produced millions of years ago. Amazing!