We develop a theory of energy relaxation in semiconductors and insulators highly excited by the long-acting external irradiation. We derive the equation for the non-equilibrium distribution function of excited electrons. The solution for this function breaks up into the sum of two contributions. The low-energy contribution is concentrated in a narrow range near the bottom of the conduction band. It has the typical form of a Fermi distribution with an effective temperature and chemical potential. The effective temperature and chemical potential in this low-energy term are determined by the intensity of carriers' generation, the speed of electron-phonon relaxation, rates of inter-band recombination, and electron capture on the defects. In addition, there is a substantial high-energy correction. This high-energy “tail” largely covers the conduction band. The shape of the high-energy “tail” strongly depends on the rate of electron-phonon relaxation but does not depend on the rates of recombination and trapping. We apply the theory to the calculation of a non-equilibrium distribution of electrons in an irradiated GaN. Probabilities of optical excitations from the valence to conduction band and electron-phonon coupling probabilities in GaN were calculated by the density functional perturbation theory. Our calculation of both parts of distribution function in gallium nitride shows that when the speed of the electron-phonon scattering is comparable with the rate of recombination and trapping then the contribution of the non-Fermi “tail” is comparable with that of the low-energy Fermi-like component. So the high-energy contribution can essentially affect the charge transport in the irradiated and highly doped semiconductors.