Meaning of Fermi energy in semiconductor We know from the band theory that in a semiconductor (of course for all metals, insulator) all energy states are not allowed. In a semiconductor there is a valence band and a conduction band, and in between energy states of them i.e energy levels laying in between valence band and conduction band are forbidden. Now when we calculate  Fermi energy of the semiconductor  we find that it lies in between  valence band and conduction band. For intrinsic  semiconductor  at T=0k, Fermi energy lies exactly half way between  valence  band and conduction  band. But we know energy levels  laying  in between  valence band  and conduction band is forbidden, and we also know that Fermi  energy is the highest energy  level of a material  that an electron  corresponds to, at T=0 k. So what is the meaning  that Fermi  energy lies in a forbidden region in semiconductor  which corresponds to valid energy level of the material at T=0k ?
 A: It is more precise to say that there are no energy levels between the valence and the conduction bands, rather than saying that they are forbidden.
The Fermi energy is not the energy of the highest level, but rather en energy characterizing the fact that the states below this energy are filled, whereas the states above this energy are empty, as described by Fermi-Dirac distribution:
$$f(E) = \frac{1}{e^{\frac{E-E_F}{k_B T}} +1}.$$
Thus, the position of Fermi energy in the gap energy region reflects the fact that (at zero temperature) all lower energy states (i.e., the states in the valence band) are filled, whereas all the higher energy states (i.e., the states in the conduction band) are empty.
Remark
One thing to keep in mind is that in the context of semiconductors one often uses term Fermi energy to mean Fermi level, i.e. the chemical potential. In a free electron gas the two are the same: they designate the position of the Fermi surface at zero temperature in the continuum spectrum. In a semiconductor the notion of Fermi energy is not very useful - the states are filled up to the top of the valence band. The Fermi level (i.e. the chemical potential), entering the Fermi distribution, is meaningful. Note however that adding the last electrons to the valence band costs zero energy, whereas adding the first electrons to the conduction band costs the gap energy, $E_g$. This is why the Fermi level is placed in the middle of the gap (for an intrinsic semiconductor).
