Try to remember back to physics when you learned about work and energy. If you do work on an object, you are giving the object energy. So, when the electrostatic force brings two opposite charges together (i.e. decreasing the distance between the charges), the electrostatic force does work on the charges. This work (since it is work done by an attractive force) decreases the potential energy of the charges (specifically their Coulombic potential).