Assume $x_1,\dots,y_2$ are real numbers. We have $$(x_1^2+x_2^2)(y_1^2+y_2^2)-(x_1y_1+x_2y_2)^2=(x_1y_2-x_2y_1)^2.$$ This is the case $n=2$ of an identity due to Lagrange.
(See more on this, positive polynomials, sums of squares of polynomials, and Hilbert's 17th problem, in this old blog post of mine.)
This means that $|x_1y_1+x_2y_2|\le\sqrt{x_1^2+y_1^2}\sqrt{y_1^2+y_2^2}$, with equality iff $$\det\left(\begin{array}{cc}x_1&y_1\\ x_2&y_2\end{array}\right)=0,$$ that is, iff either there is a constant $c$ such that $x_1=cy_1$ and $x_2=cy_2$, or else $y_1=y_2=0$.
Since $a\le|a|$ for any real number $a$, it follows that $x_1y_1 + x_2y_2 \leq \sqrt{x_1^2 + x_2^2}\sqrt{y_1^2 + y_2^2}$, with equality as above, except that now we further need $c\ge 0$.