1. Attraction leads to stability and when a substance is stabilised it is least energetic and releases energy. So, when we get energy from the system, the energy is negative energy.
2. Repulsion leads to un-stability and when a substance is not stabilised it is most energetic and adsorbs energy from the environment. So, when energy is taken from the system it is positive energy.