Based on some of your comments, I think what might be tripping you up is the first statement you started with:
From the Bohr's atomic model, it is clear that electron can have only certain definite energy levels.
and
...If suppose, we assume electron losses total energy, electron can't stay in any particular shell, as it would not have that particular value of energy.
That may be true for Bohr's atomic model, but Bohr's atomic model is wrong. And electron does not have to be in a particular, definite shell or energy level. Rather, any electron state is a superposition of states of definite energy level (energy eigenstates).
That means the expectation value of a hydrogen electron state is going to look like
$$\langle E\rangle = \sum_n |a_n|^2 E_n\text{,}$$
where $\{a_n\}$ are arbitrary complex values with $\sum_{n>0}|a_n|^2 = 1$ and $E_n$ are energy levels in increasing order. Because of the sum-to-$1$ condition, taking any portion along the other energy eigenstates will increase energy compared to the ground state.
In other words, even if the electron state does not have a definite energy, you still can't go lower than the ground state.
Suppose, I have a cup of hot coffee on the table. It will be continuously losing energy in the form of heat, but it stays on the table, though there was a energy loss. Now, all of a sudden, I take off the table, the cup of coffee converts it potential energy into kinetic energy to come down.
If you don't shake the table, the coffee cup will sit there, forever. Similarly, nothing perturbs the electron in an excited energy eigenstate, then it simply will never decay. It cannot: energy eigenstates are stationary; they do not evolve into anything other than themselves.
However, being completely without external perturbation is actually impossible. The uncertainty principle provides the electromagnetic field with vacuum fluctuations, which will perturb the electron even if nothing else in the environment does. In your analogy, this (or something else) provides the "shaking of the table" for the electron. Once the electron state gains even a tiny component in some other energy eigenstate, the state can evolve in time.
In other words, one can think of spontaneous emission as a particular type of stimulated emission where it's the vacuum that does the perturbing.
The electron itself doesn't "know". The entire system "knows" what its own energy levels are. That is, the system can make transitions only to states that exist. Don't think of the electron, think of the entire system that contains the electron.
The system will stay at the excited level for some period of time depending on the strength of the coupling between the system and the electromagnetic field, and the intensity of the field. Stronger coupling means shorter lifetime. And stronger field means shorter lifetime. This last effect is stimulated emission.
There is never a situation where the field has no intensity. The ground state of the electromagnetic field has "zero-point fluctuations", required by the uncertainty principle. No energy can be extracted from the field in the ground state, so it behaves like zero intensity. But the zero-point field can induce transitions in an atom just as in stimulated emission. This is the origin of spontaneous emission, the process by which an isolated excited system makes transitions to lower energy states.
Best Answer
For the same reason any physical system has more energy than its ground state: because some thing or other gave it the extra energy. It's hard to give a more concrete answer on something this general, though, because how the energy gets there will vary wildly depending on the situation.
Some common reasons:
There's plenty of other ways to arrange this, but either way you need an environment which is energetic enough, or a mechanism that is directly pumping energy into a specific transition.