It was a classical problem going back to Mengoli to find a closed expression for the sum of inverse squares. This was solved by Euler, who saw more generally how to evaluate $\zeta(2k)$ at the positive even integers. Later, Euler "computed" the values of $\zeta(s)$ at negative integers as well and conjectured the functional equation of the zeta function. Euler also saw the connection with prime numbers and used the Euler factorization for estimating the number of primes up to $x$.
Most of Euler's results were made rigorous by Dirichlet (his proof of the infinitude of primes in arithmetic progression was built on Euler's results) and Riemann (who interpreted $\zeta(s)$ as a function on the complex plane, proved the functional equation, and indicated how the number of primes is connected with zeroes of the zeta function). There are many more names that should be mentioned (Kummer, Dedekind, Mertens, Landau, ...).
In any case, it was Euler who stumbled upon the zeta function more or less by accident, and he already recognized its importance.