Why Fermi energy is in between band gap? It may seems like a copied question Question
But It still didn't clear my doubt.Consider the following figure 
 
As you can see the fermi energy (Fermi energy)
lies in between the bandgap and figure shows the Fermi-dirac distribution.At Fermi energy there is $50 \%$ that the state is occupied by an electron but it's a forbidden region and it is sure that no electron can attain this energy state,then why there is a finite probability that electron will occupy these states? Please correct me if I some where mistaken.
 A: 
At Fermi energy there is 50% that the state is occupied by an electron [...]

This is not quite right.  The correct statement is that the probability that a state with energy $E=\mu$ is occupied is 50%.  There is no reason to think, however, that there exists such a state in the first place.

Consider a system of non-interacting fermions with two energy levels - a ground state with energy $E=0$ and and excited state with energy $E=\epsilon$.  The system can exchange both energy and particles with a reservoir at temperature $T$ and chemical potential $\mu$.
The standard trick is to look at each energy level like a separate subsystem.  The ground state level has two possible configurations - one in which it is unoccupied, and therefore has $E_0=0$ and $N_0=0$, and one in which it is occupied, and has $E_0=0$ and $N_0=1$.
Similarly, the excited state has two possible configurations - one in which it is unoccupied, and has energy $E_1=0$ and $N_1=0$, and one in which it is occupied, and has energy $E_1 = \epsilon$ and $N_1=1$.
The Boltzmann factor for a configuration with energy $E$ and particle number $N$ is $e^{-(E-\mu N)/kT}$.  Because the particles are non-interacting, the energy of a particular configuration is simply equal to the particle number times the energy of the level under consideration.  For the ground state, we therefore have that the Boltzmann factor is $e^{-(0 -\mu) N_0/kT} = e^{\mu N_0/kT}$.  For the excited state, we have $e^{-(\epsilon - \mu)N_1/kT}$.
The partition functions for each energy level are
$$Z_0 = \sum_{N_0 = 0}^1 e^{\mu N_0/kT} = 1 + e^{\mu/kT}$$
and
$$Z_1 = \sum_{N_1 = 0}^1 e^{-(\epsilon-\mu) N_1/kT} = 1 + e^{-(\epsilon - \mu)/kT}$$
The probability that the ground state is occupied is therefore
$$P(N_0=1) = \frac{e^{\mu/kT}}{1 + e^{\mu/kT}} = \frac{1}{e^{-\mu/kT} + 1}$$
and for the excited state,
$$P(N_1=1) = \frac{e^{-(\epsilon-\mu)/kT}}{1+e^{-(\epsilon-\mu)/kT}} = \frac{1}{e^{(\epsilon-\mu)/kT}+1}$$

All of this analysis has occurred without specifying either $\epsilon$ or $\mu$.  If the excited state has $\epsilon=\mu$, then the probability that it would be occupied would indeed be $\frac{1}{2}$, but why on Earth should that be the case?
The key takeaway from this is that, given some fixed chemical potential $\mu$ and temperature $T$, the probability that an energy level (in a system of non-interacting particles) is occupied is exclusively a function of the level's energy, and in particular does not depend on which energy levels actually exist in the first place.  Different systems have different allowed energy levels, and there is no reason whatsoever to think that one of them would happen to coincide with $\mu$.

To supplement this answer, note that $\mu$ is set by the total particle number of the system.  The average total occupancy of the system is
$$N = \langle N_0\rangle + \langle N_1\rangle = \frac{1}{e^{-\mu / kT}+1} + \frac{1}{e^{(\epsilon-\mu)/kT}+1}$$
We can therefore consider $N=N(\mu)$.  Differentiating with respect to $\mu$, we find that $N'(\mu)>0$; since $N(\mu)$ is monotonic, it follows that it is invertible, and we can (in principle) solve for $\mu$ as a function of $N$.
This means that there is a one-to-one correspondence between the chemical potential and the total particle number.  Given a set of available energy levels and a temperature $T$, a choice of total particle number $N$ uniquely determines the chemical potential $\mu$.  In particular, there is no reason that $\mu$ should coincide with any of the allowed energy levels, and in general it does not.
A: You need Fermi-Dirac distribution to predict how the density vary with temperature in both valence band and in conduction band (since there are thermal fluctuactions that allow electrons to promote to the conduction band). Anyway, in extrinsic semiconductor there are electrons or holes inside the gap.
A: Let's Begin with Introducing energy state:
Energy state: s orbital has two energy states with same energy. P has 6 energy states with same energy.
Now
Fermi Dirac fxn gives you the probability of finding filled energy states at given Energy value provided there exists available energy states at that energy value.
Not Only at Fermi Level, The Femi Distribution fxn gives values b/w 0-1 at every Energy Values b/w Ev and Ec which lie in forbidden gap, as well!
Your Problem is
In forbidden gap there exists no available energy states hence no electrons!
But at certain energy b/w Ev and Ec, Fermi fxn still gives a no. say 0.1
Now, 0.1 here says that if there had been energy states available for electron then there were 1% probability of finding filled energy state. Finding a filled energy state is equivalent to finding electron.
Hence if there had been energy state available for electrons then there was 0.1 probability of finding electron at this energy value lying in forbidden gap.
This behavior is beautifully controlled by density of states fxn. which ensures there is no Available energy state present b/w Energy values Ec and Ev.
Yet, We have traps in crystal structures which manifests themselves in Energy Band Diagram as Trap Energy States.
These Trap Energy States may have Energy Values lying-in forbidden gap.
The Probability of finding electron in forbidden gap becomes real and guess what Fermi distribution fxn gives that probability. (as we have energy state present)
