By Rational Root Theorem, all rational roots of a polynomial are in the form $\frac{p}{q}$, where $p$ divides the constant term $-5$ and $q$ divides the leading coefficient $1$. One such root is $5$. Factor the polynomial by dividing it by $x-5$.
$$\left(x-5\right)\left(x^{2}+2x+1\right)$$
Consider $x^{2}+2x+1$. Use the perfect square formula, $a^{2}+2ab+b^{2}=\left(a+b\right)^{2}$, where $a=x$ and $b=1$.