You must understand that electric and magnetic fields are not really independent of each other, but rather they are infact simply two different aspects of a single entity called an electromagnetic field. This field manifests itself in different forms based on choice of frame, and other factors.
Now, there are some interesting facts, about electric fields and magnetic fields. One very important fact is that changing electric fields produce a magnetic field, and that changing magnetic fields produce an electric field. These are the Ampère's and Faraday's laws respectively. I won't discuss too much about them here, but head to the Further Reading section of this answer if you'd like to dig deeper.
Anyway, in an electromagnetic wave, the electric field intensity is an oscillating value. This electric field that constantly changes, produces a magnetic field. The magnetic field, like the electric field, is also a sinusoidal function, which in turn, generates another electric field. This interconversions keep on going, and the wave propagates as a result. The energy of the wave remains constant, and simply transfers back and forth between the electric and magnetic manifestations of the electromagnetic wave. This energy can be carried at a very specific speed $c$ away from the source of the elecromagnetic wave and taken elsewhere. This is exactly how the Sun can transfer energy to the Earth.
Further reading:
- Ampère's Law
- Faraday's Law
- Electromagnetic Wave