How did Kepler come to the potencies in his Third Law?

How did Kepler come to the conclusion, that exactly the square of the period and the third potency of the great semi-axis of the ellipse is proportional? Why is only square divided by cubic = constant? Why do other dimensions not work? Kepler certainly did not simply try all potencies. Isn't this a similar problem to Fermat's last theorem?

• Fermat's last theorem is related to (positive) integer solutions of the equation $a^n + b^n = c^n$. Since planetary orbital periods and distances are not constrained to be integers, Fermat's last theorem isn't applicable.
– user24157
Jul 10 '20 at 9:30
• Yes, makes sense thanks! But do you know how Kepler comes to ^2 and ^3 and not any other dimension?
– iwab
Jul 10 '20 at 10:29
• I wonder if answers to How did Kepler “guess” his third law from data? are helpful?
– uhoh
Jul 10 '20 at 10:30

If you plot the log of the period against the log of the semi-major axis then it is obvious that $$P^2 \propto a^3$$. Any other power law relationship simply wouldn't fit. 