I've been reading about lattice energy, it says that during the formation of ionic compound the ions formed due to electrostatic force are attracted to each other and libration of energy takes place due to this the total potential energy of the system decreases. I want to know how the potential energy in this case is decreasing?
If you have two oppositely charged particles they attract each other.
The particles have potential energy because if the two charges are released they can do work and in doing so their potential energy decreases as they come closer together.
When the charges are closer together the charges do not have the capability of doing as much work and so have a smaller amount of potential energy.