Suppose we have a system of equations $Ax=b$ which has no solutions. Then, we need to find a certain $\bar{x}$ such that $A\bar{x} - b$ is minimal. Apparently this $\bar{x}$ we're looking for is a solution to the equation $A^TAx = A^Tb.$ This has something to do with projections and orthogonality but I don't understand how and why. I have tried looking online but I can't find intuitive explanations (i.e. geometric) or simple derivations as to why $\bar{x}$ must satisfy $A^TAx = A^Tb.$ (where the transpose comes from, etc.) One explanations I'm looking at states it as follows:
$Ax-b$ is the orthogonal projection of the zero vector $0$ on the set of vectors of the form $Ax-b, x \in \mathbb{R^n}$. It is characterized by the condition that $A\bar{x} -b$ is orthogonal to all vectors $Av, v \in \mathbb{R^n}$.
But I really don't understand what is meant by this. Can anyone clear this passage (or the equation itself) up for me?