polynomial curve fitting and linear algebra In this text, why does the polynomial equation have to be to the $4$th degree? Why couldn't all $5$ points lie on a polynomial of say degree $2$?

 A: They might lie on a quadratic, but in general they will not.  If you fit five points that happen to lie on a quadratic using a 4th-order polynomial, your fit will be:
$$0 x^4 + 0 x^3 + a x^2 + b x + c$$ 
A: The $5$ and $2$ in the question body are irrelevant to the general problem of Legendre polynomial interpolation.
To give a general answer, consider a set of $m$ distinct points on $\Bbb R^2$: $\{(x_i,y_i)\}_{i = 1,\dots,m}$.  We want an interpolating polynomial $f(X)$ of degree $d$ in $X$ with real coefficients
$$f(X) = \sum_{j=0}^d a_j X^j, \quad a_j \in \Bbb{R}$$
so that
$$\forall i \in \{1,\dots,m\}, \quad y_i = f(x_i) = \sum_{j=0}^d a_j x_i^j. \tag1\label1$$
OP asks why $d$ is chosen to be $m-1$?
To see this, rewrite \eqref{1} into $Y = Xa$, where
$Y = (y_1,\dots,y_m)^T$, $a = (a_0,\dots,a_d)^T$ and the $m \times (d+1)$ matrix $X = (x_i^j)_{(i,j)\in\{1,\dots,m\}\times\{0,\dots,d\}}$.  The question becomes solving for $a$ in this condensed equation.
This is solvable as long as the column vector $y$ (, which collects the given $y$-coordinates,) is in the column space of $X$.
In linear-programming, matrix $X$ often has more columns than rows.  Contrarily, in statistics, matrix $X$ often has more rows than columns, so they have to think of pseudoinverse $X^+$.  Despite $ XX^{+}X=X$ and $ X^{+}XX^{+}=X^{+}$, we can't say that $a = X^{+}Y$.  In general $X(X^+Y) \ne Y$, it only minimizes the error (in the sense of Euclidean norm)
$$X^+Y \in \mathop{\mathrm{argmin}}_{a \in \Bbb{R}^{d+1}}||Y-Xa||_2.$$
If $X$ has linearly independent rows, $XX^+=I$.  A square matrix is a minimal choice.  Luckily, if $X$ is a square matrix, then $\det(X)$ is just the Vendermonde determinant, which is nonzero, so $a = X^{-1}y$.
