For the "ancients", "numbers" were integers or fractions. They did not have a concept of a real number. (They had an equivalent concept of length in geometry, but analytic geometry did not exist, and they did not think of geometric problems
as problems about equations. Geometric problems had to be solved by construction). Interest to the theory of whole numbers in Greece can be traced back to Pythagoreans who defined the main objects (primes, squares, etc.) and
started to study their properties. According to the tradition, Pythagoras claimed that "numbers rule the world" (he meant integers). This sweeping claim
was based on his discovery that musical intervals correspond to certain fractions. (In the long run he was right as we know: the basic laws of nature have mathematical formulation).
The early stages of development of Diophantine equations are unknown to us.
They were usually formulated as word problems. See, for example
Archimedes' cattle problem on Wikipedia as one especially famous problem. It is about an equation of the same type you give, it is called Pell's equation nowadays. This is an isolated example, and we do not really know why exactly people were interested in such problems. Perhaps indeed out of curiosity. Most of the important mathematics was invented like this, by the way, out of curiosity.
Then, 3 centuries after Archimedes, we have the book of Diophantus which treats
a lot of much more complicated problems like that. The modern development starts essentially with Fermat who read Diophantus...a millenium later. Nowadays this is one of the most
fashionable areas of mathematics. There are some applications, but mostly it is
driven by curiosity.
Ancient Babylonians also had taste to these problems, for example they knew how to find all solutions of $a^2+b^2=c^2$ in positive integers. Whether the Greeks
started the subject independently or it came from Babylonia, it is not known.