This is not a full answer but information I find useful throwing in. As @Conifold suggested in a comment, we saw a usage of square physical quantity in Kepler's third law, and he indeed might drew inspiration from his work Optics on the spreading of light:
Just as [the ratio of] spherical surfaces, for which the source of light is the center, [is] from the wider to the narrower, so the density or fortitude of the rays of light in the narrower [space], towards the more spacious spherical surfaces, that is, inversely. For according to [propositions] 6 & 7, there is as much light in the narrower spherical surface, as in the wider, thus it is as much more compressed and dense here than there. (Source: Wikipedia).
It should be noted however that in his Astronomia Nova Kepler, though he draws some similarities between the emission of light and gravity, does not recognize the inverse square distance law with respect to gravity; rather he establish there the "distance-law" (which later became the "area law" though not entirely equivalent) which missing the square. Kepler indeed compares gravity with Magnetism -- but even in the case of Magnetism no one up to his time - so it seems - has formulated any "distance-square" relation.
According to Wikipedia the first to suggest a case of inverse square law, was the French astronomer Ismaël Bullialdus.