Essentially, metals will form ionic compounds with non-metals of a lower period because the energy released in the formation of the bond is vastly greater than the energy required to promote an electron.
Reactions which cause an increase in entropy (I.e. kinetic instability) or a decrease in enthalpy (I.e. Thermodynamic instability) will be favourable and will naturally occur.
In this case, only considering enthalpy is particularly relevant.
So a decrease in enthalpy will occur when the energy of the products is less than the energy of the reactants, and if this is the case, the reaction will be favourable and occur naturally.
It is important to note that as we’re talking about an ionic bond, e.g. NaI, only one electron from the sodium atom is given to the iodide atom.
So you’re correct, that promoting this electron requires energy (or is an endothermic process in itself) because energy levels are quantised, and so the electron must be promoted to a higher level to be a part of the iodine ion.
However, the energy released by the formation of the ionic bond is vastly greater than the energy required to promote the electron, and so the net change of the reaction will be that the energy released is greater than the energy supplied, and so the reaction is exothermic, leads to a decrease in enthalpy, and so is favourable.
The presence of the additional electron does not decrease the energy of the other valence electrons as they are quantised and do not change their energy level.
The concept of bond formation releasing energy can be conceptually difficult to grasp, so it is best to think of bond formation as the opposite of bond-breaking, which it inherently is. And since it will obviously require energy to be supplied in order to break a bond, by extension, forming a bond releases energy.