How Earth protected from the gamma rays generated by Sun?
That's a good question and I think the answer may surprise you. It turns out that indeed, there's a lot of gamma ray radiation being produced in the sun's core from fusion reactions, so why are we not bombarded by gamma ray radiation? Those gamma ray photons need to escape from the sun's core, into the outer edge, and then finally from the surface. These photons are colliding with matter constantly, resulting in a photon diffusion process. It actually takes the average gamma ray photon about 170,000 years to diffuse out of the radiative zone. Once a gamma ray actually diffuses outward to the surface as a result of the constant collisions it has been converted into millions of visible wavelength photons.
more here: Solar Core Wiki
As you can read on wikipedia
Sun produces Gamma rays as a result of the nuclear fusion process, these super-high-energy photons are converted to lower-energy photons before they reach the Sun's surface and are emitted out into space. As a result, the Sun does not emit gamma rays. The Sun does, however, emit X-rays, ultraviolet, visible light, infrared, and even radio waves not to mention neutrinos.
Gamma ray photons produced by fission make their arduous journey to the surface of the Sun, they are continuously absorbed by the solar plasma and re-emitted to lower frequencies. By the time they get to the surface, their frequencies are mostly only within the IR/visible light/UV spectrum.
Actually, we don't need a lot of protection from solar gamma rays because they never reach us. Here's Wikipedia's take on the matter:
Although the Sun produces Gamma rays as a result of the nuclear fusion process, these super-high-energy photons are converted to lower-energy photons before they reach the Sun's surface and are emitted out into space. As a result, the Sun does not emit gamma rays.
So while lots of gamma rays can be formed during nuclear fusion, not many escape the Sun. We do have to worry about ultraviolet rays, but the ozone layer gives us a lot of help with that.
Note: NASA has a page that briefly discusses the Sun and gamma rays. There is an inaccuracy or two regarding Earth's magnetic field's ability to stop gamma rays (it can not), but it should prove helpful.