Kepler did not discover the theory of gravity. Isaac Newton is credited with the discovery of the law of universal gravitation in the late 17th century.
Kepler, a contemporary of Galileo, is known for his three laws of planetary motion, which describe how planets orbit the sun. These laws provided the foundation for Newton's later work on gravity.