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:
- The atom absorbs a photon of the relevant energy.
- The atom is kicked into that excited state by a collision, say, with an electron in a discharge tube.
- The atom is in a hot gas with temperature $T\gtrsim\Delta E/k_\mathrm B$, and it regularly acquires energy $\Delta E$ in collisions with other atoms in the gas.
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.
The key point missing from most efforts to answer this question are that the Sun has a temperature gradient with depth. If it were (somehow) isothermal, then indeed the absorption and emission processes would cancel and the Sun's spectrum would be a smooth blackbody.
The photons we see from the Sun, were those that were able to escape from its photosphere - an outer layer only a few hundred km in thickness.
The interior of the Sun is hotter than layers further out and the radiation field approximates to a blackbody, with a radiation flux that is strongly temperature dependent. The strong temperature dependence, combined with the negative temperature gradient means that the solar spectrum is produced by the hottest layers we can see.
Why the emphasis? Well, the depth we can see into the Sun is wavelength dependent. Where there are strong radiative transition probabilities, the light coming from the interior is absorbed. The re-emitted light (it has to be re-emitted if the material is in thermal equilibrium) is emitted in a random direction and a negligible fraction comes towards us.
I think there are two key points. One is the random direction of the re-emission of absorbed energy, but the other is the temperature gradient which means there is a clear outward directionality to the net radiative flux which means you can treat the Sun as a succession of cooler "slabs" as one moves outward.
The net effects are absorption lines. A good way to think about the solar spectrum is that at each wavelength you are seeing a (roughly) blackbody spectrum emitted at the temperature of the layer from which photons at that wavelength can escape. Thus the bottom of an absorption line is emitted at cooler temperatures, closer to the "surface", whilst continuum comes from hotter, deeper layers, but at wavelengths where the opacity is lower so that the photons are still able to make it out.
Best Answer
This statement confuses a semi-classical model (Bohr model of atoms) with the final quantum mechanical solution for the atomic physics spectra. The Bohr model has been superseded by the solution of Schrodinger's equation. The solutions for the Hydrogen atom are the same as for the Bohr model, but it is not the electrons that gain and lose energy with the absorption and emission of a photon but the whole atom.
Quantum mechanics solutions give the probability of interaction, so one cannot talk of electrons jumping . When a photon is absorbed the QM true description is " the atom exists with an electron in an orbital of a higher energy state". The Bohr orbits are an approximation to the statistical accumulation of the orbitals .
This should be " But what if the atom is already excited state? "
yes
No such rule.
Here is an article on differences between absorption and emission spectra, which are higher order or semantic(language used, "as absorption has continuous spectra because the lines are a depletion of the continuum") differences.
The video is talking of the fact that in a real experiment, de-excitation of an atom can take multiple routes which cannot be available when shining light to get an absorption spectrum.