Energy is released when an electron transitions from one energy level to another. In contrast, the same amount of energy is needed to carry out the process, the other way around, from the bottom elevation to the upper one.
What occurs when an electron transitions from one energy level to another?
The energy of the electron drops when it changes levels, and the atom releases photons. The electron emits a photon when it transitions from a greater to a lower energy level. The energy emitted is precisely the energy that is lost when an electron moves to a level with less energy.
An atom's electrons have negative energy. The electron must be given energy in order to be removed from the hydrogen atom, as shown by the negative sign. The quantity of energy in the atom will rise by supplying the electron with energy. Similar to how a ball on Earth chooses to rest in valleys rather than hills, the electron wants to spend the majority of its time at a lower energy level.
For a brief period of time, the electron remains in an excited state. The energy required to bring the electron to its lower-energy state will be released when the electron transitions between excited and unexcited states.