Rigorous notion of limit for special cases arose in the work of Eudoxus and Archimedes, when determining the length of a circle, volume of the pyramid etc. (The work of Eudoxus did not survive, we know about it from Euclid
and ancient historians of mathematics).
The argument to find
these limits was called the "method of exhaustion". It is equivalent to the modern notion of limit, in the special cases they studied, but does not coincide with it exactly. And applies only to special cases, they had no general definition.
The length of the circle for example is DEFINED as the limit of perimeters
of inscribed polygons, and Euclid and Archimedes were dealing with it
absolutely rigorously from the modern point of view, except in the cases where Archimedes himself clearly says that his arguments are heuristic.
Same applies to many other works of Archimedes on areas and volumes. They are all defined as limits, and Archimedes was able to find them, and
his arguments are rigorous from the modern point of view.
The modern definition of a limit was systematically used by Cauchy in the early 19 century.
But many people in between were talking about the limits, and were able to compute them, with various degrees of details and rigor. The degree of rigor in calculus similar to that of Archimedes was achieved only in the second half of 19th century.
Like many other mathematical notions, one can say that
the general notion of limit "slowly evolved" rather than was "invented" by some person at some definite time. Cauchy, who played an important role in formalization of calculus still made "elementary mistakes" from the point of view of a modern student. (For example he claimed and "proved" that the limit of continuous functions is continuous. His proof is valid if by the "limit" one means "uniform limit", but he did not state the definition of uniform limit carefully).
EDIT. Ancient Babylonians had an algorithm which approximated square roots of integers
by rational numbers with any given accuracy. So one can say that they were able to compute these limits. However they gave no definitions and did not prove anything (at least no traces of proofs survive).
All this intends to show that the limit was not invented at some definite time, but that people just studied it, and the modern notion slowly evolved from these studies; the evolution took about 2500 years or more.
Your second question: "for what purpose?" has an evident answer: to define and compute the things like the length of a circle or the volume of a pyramid. (It is a remarkable theorem of Max Dehn, solving a problem of Hilbert, that the volume of a pyramid cannot be DEFINED without the notion of a limit. Unlike the area of a triangle which can be).