Dear student,
Electrons are stable in the ground state and have low energy, when they absorb energy (in the form of photons) they get excited from lower enery level to higher energy level, they are unstable in the higher level, due to this reason there is increase in the energy of the atom in the higher level.
Regards