Why there is a distance dependence in coulombs law if photons can travel to infinity? Why there is distance dependence at all?
The simplified explanation is that photons spread out as they get further away from the source. And the strength of the electromagnetic force is roughly related to number of photons per unit cross-sectional area, not just the number of photons itself. So as the photons spread out and the area grows (as $r^2$), the strength of the force drops (as $1/r^2$).
For more details on the connection between photons and the electromagnetic force, you might want to see this question and others like it.