Isaac Newton formulated the law of universal gravitation, which adequately explained the motion of all bodies in space known at his time. He also showed it is the same law that is causing everyday objects to fall on Earth.
In his famous phrase “hypothesis non fingo,” Newton stated that he did not know what causes gravity and refused to speculate. Flat-Earthers use it to discredit him. In reality, just because he did not know what causes gravity, it does not mean his law of universal gravitation is wrong.
In 1687, Isaac Newton wrote his book “Philosophiæ Naturalis Principia Mathematica” which explained his law of motion, his law of universal gravitation, and the derivation of Kepler’s law of planetary motion.
In the second edition of the book published in 1713, Newton added the essay “General Scholium,” where he stated his famous “hypotheses non fingo.” He said he had not discovered the reason for the properties of gravity from phenomena, and he refused to speculate.
Newton knew how gravity affects things which he described in his law of gravity. He did not know what causes the phenomenon he described as gravity. Just because he did not know the cause, it does not mean his law of gravity is wrong.