We start with $\|ax-by\|^2$ since it is a non-negative number, with the hope to derive the Cauchy-Schwarz inequality from a trivial inequality. For instance, by just picking $a$ and $b$ as $1$ we have
$$0 \leq \|x-y\|^2 = \|x\|^2+\|y\|^2 -2\langle x,y\rangle \tag{1}$$
from which it follows that
$$ \langle x,y\rangle \leq \frac{\|x\|^2+\|y\|^2}{2}\qquad\text{(trivial inequality)}.\tag{2}$$
Now we may exploit a symmetry: if we pick some $\lambda>0$ and replace $x$ by $\lambda x$ and $y$ by $\frac{1}{\lambda}y$ the LHS of $(2)$ is unchanged. In particular
$$ \forall \lambda>0,\qquad\langle x,y\rangle \leq \frac{\lambda^2\|x\|^2+\frac{1}{\lambda^2}\|y\|^2}{2}\qquad\text{(less trivial inequality)}.\tag{3}$$
Given some $\|x\|,\|y\|>0$, we may pick $\lambda>0$ such that the RHS of $(3)$ is minimal.
By the AM-GM inequality the RHS of $(3)$ is $\geq\|x\|\|y\|$, but equality is attained if $\lambda=\sqrt{\frac{\|y\|}{\|x\|}}$.
$$ \langle x,y\rangle \leq \|x\|\|y\| \tag{4} $$
Is the Cauchy-Schwarz inequality. By performing a backtracking in the outlined proof we have that equality holds iff $x,y$ are linearly dependent. We also have that $(4)$ holds for any positive definite inner product $\langle \cdot,\cdot\rangle$, where $\|x\|$ is defined through $\|x\|^2=\langle x,x\rangle$.