It's to do with Geometry.

If something, (gravitational field, heat energy, sound etc) is radiating equally in all directions and you draw a sphere around the source, the amount of this thing flowing through a square metre of the sphere (the flux density) will be equal to the total flux from the source divided by the area of the sphere (assuming it is spread evenly).

The area of the sphere is 4πr^{2}, so the density of the flux will be 1/4πr^{2}. The r^{2} is on the bottom of the formula so it is proportional to one over r squared: The 'inverse square' law.

The argument also applies when the spread is not symmetrical or when you are just concerned with a particular direction; the 'flux density' is still proportional to 1/r^{2} .

Over large distances, we believe that space is not truly uniform (Euclidian or like a 3D graph) , the the inverse square law will not apply exactly. Gravity can bend space and cause a lensing effect on the light from distant objects. This can be looked upon as failure of the inverse square law.