Consider a system of two charges containing two charges q1 and q2 fixed at two points A and B. AB=r1. Now q2 is taken from B to a new point C along AB and AC=r2
If the charge is displaced from r to r+dr then work done
dw=F.dr
total work done
Change in potential energy
U(r_2)-U(r_1)=-W