Mechanism of conversion of electrical energy to EM energy in LEDs
As others have mentioned, photoelectric effect (solar cells) and photoemission (LEDs) are pretty much inverse processes.
My high-school-physics mental model is like this:
Electrons orbit a nucleus in shells.  The physical size of those shells dictate how much energy the electrons have (and somewhat depend on the type of atom).  Thus, to move from one shell to another the electron needs to gain or lose a specific amount of energy.  A &quot;free&quot; electron can be thought of as being in the &quot;next&quot;, unfilled shell of the atom.
The actual lingo, then, moves to energy &quot;bands&quot;.  The outermost electrons, in the valence shell, have an energy corresponding to the &quot;valence band&quot; and free electrons are in the unfilled shell corresponding to the &quot;conduction band&quot;.  The amount of energy between the two is the &quot;band gap&quot;.
So, in the photoelectric effect we have a photon whose energy corresponds to the band gap (or maybe more) coming in and transferring its energy to an electron in the valence band.  That gives the electron enough energy to jump to the conduction band, and if we put an electric field around the thing that field will carry away the electron, giving us current.
In photoemission we have some extra electrons provided by an external current.  When they come across an atom with a vacancy (because we have p-doped material...) they are captured by the atom, moving from the conduction band to the valence band, losing an amount of energy corresponding to the band gap in the process.  That lost energy comes out as a photon*, and the frequency (i.e. color) is inversely proportional to the amount of energy, which is fixed.
As to questions of efficiency: A big factor that is missing here is that with an LED all of the energy you put in is being converted to a single wavelength, and it can be very efficient.  With a solar cell a single wavelength can be converted with good efficiency but the light you're putting in is a very broad spectrum of wavelengths, and not all of these have enough energy to move an electron across the band gap.  Of interest may be multi-junction solar cells, which combine multiple materials to have band gaps capturing different parts of sunlight's spectrum.
*The lost energy can actually be split between the photon and a phonon, which is some vibration of the crystal latice.  This has something to do with quantum spin and is way, way above my head, but the important take-away is that practical LEDs are made with &quot;direct band gap&quot; materials where all of the energy goes into the photon and there is none &quot;lost&quot; as a phonon.  (Lost as in doesn't produce light.)