J. Dieudonne, A History of Functional Analysis, is a good reference.
Inner product had its genesis in notions of orthogonal function expansions, such as the Fourier Series. People often get this backwards.
Orthogonality of functions was observed first in connection with the classical Fourier Series, well before Fourier looked at it. They were trying to solve the wave equation for the vibrations of a string given an initial displacement, and they had found much earlier that the $\sin$ and $\cos$ functions were well-suited. It was Clairaut and Euler who discovered integral orthogonality conditions that allowed them to determine what the coefficients in the Fourier series expansion of the initial data would have to be. But nobody at that time suggested every function could be so expanded; so they saw the conditions as consistency relations on the initial data instead. These developments took place roughly in the era of 1760-1800.
It was Fourier who declared that "arbitrary" functions could be expanded in a trigonometric series on $[-\pi,\pi]$, and that idea was met with such great opposition that his later treatise on Heat Conduction was banned from publication for 20 years until he could gain power and force it to be published. In that work, Fourier looked at other types of orthogonal expansions coming out of his "separation of variables" technique. This was a new direction entirely, and is the reason for Fourier's name being attached to the subject, even though he did not discover orthogonality relations. Fourier's treatise was written around 1805. and finally published ~1827.
Cauchy proved what is now known as the Cauchy-Schwarz inequality for Euclidean space around 1825. Oddly enough, the Euclidean dot product did not get connected in any serious way with orthogonal function expansions until decades later. Cauchy's inequality was generalized from sums to integrals around 1859, but nobody noticed; it was just a novelty. (By the way, that was right about the time Riemann came up with his integral, with the intent of studying the convergence of the Fourier series. Until then, there was no rigorous integral!) In the decades that followed, researchers began looking at Calculus of variations problems and their solutions. And there was a landmark paper by Schwarz where he proved the Cauchy-Schwarz inequality for integrals, and used it to define an integral distance (norm in today's language) that would satisfy the triangle inequality and could be used to approach solutions of minimal surface (I believe.) This was in the 1880's, which was around the time a real number was rigorously defined for the first time.
Now there was an explosion of rigor, and everything began to focus on solutions of PDEs, including Fourier's, and the convergence of orthogonal expansions. Lebesgue, also with the expressed intent of studying convergence of Fourier expansions, invented his integral. Fredholm was looking at integral equations as a way to solve differential equations, and he defined the modern notion of an operator. Compactness was evolving, and compactness criteria for function spaces was being used by Fredholm. Then, in the golden age of rigor, Hilbert in the first decade of the twentieth century laid out axioms for $\ell^{2}$. Though uncertain, it seems to be that the definition of an inner product space was Hilbert's, at least according to Dieudonne.
So, inner product came after and in response to general notions of orthogonal eigenfunction expansions in infinite-dimensional spaces. There's a chart in Dieudonne's book that shows how the most abstract came first, and finally filtered down to Matrix Analysis. And it was very clear that inner product was a form on a single space. The notion of duality came decades later, only once people found that they were forced to separate the dual from the space. In the 1920's, the standard texts on the subject still did not separate the space from its dual.