What year did Kepler discover the gravity theory?

He didn't. Isaac Newton formulated the theory of gravity in 1687.