Light behaves mainly like a wave but it can also be considered to consist of tiny packages of energy called photons. Photons carry a fixed amount of energy but have no mass. The energy of a photon depends on its wavelength: longer wavelength photons have less energy and shorter wavelength photons have more. Red photons, for example, have less energy than blue ones.
Until about 1900, scientists only understood electromagnetic radiation to be made up of waves. Then Max Planck and others were studying the photoelectric effect and they found that certain types of metal and other materials will eject electrons when light shines on them. They expected that the number of electrons ejected from the metal would increase with the intensity or brightness of the light directed towards the metal. What they found instead, was that the wavelength of the light was what affected the number of electrons ejected.
More energetic wavelengths such as blue and ultraviolet caused more electrons to be ejected than red or infrared wavelengths. They also found that increasing the intensity of light increased the number of electrons ejected, but not their speed. Planck realized that the energy of the electromagnetic radiation was proportional to its frequency, but admitted that he didn't understand why this was the case and said it was lucky guesswork.
Einstein was the first to explain what was happening. He theorized that electromagnetic energy comes in packets, or quanta which we now call photons. So light behaves as a wave and as a particle, depending on the circumstances and the effect being observed. This concept is now known as wave-particle duality. Einstein won the 1921 Nobel Prize in Physics "for his services to Theoretical Physics, and especially for his discovery of the law of the photoelectric effect".