\(\left(x^2+x+1\right)\left(x^2+x+5\right)-21=x^4+x^3+5x^2+x^3+x^2+5x+x^2+x+5-21=x^4+2x^3+7x^2+6x-16=\left(x-1\right)\left(x+2\right)\left(x^2+x+8\right)\)
\(=\left(x^2+x+1\right)\left(x^2+x+1+4\right)-21\)
\(=\left(x^2+x+1\right)^2+4\left(x^2+x+1\right)-21\)
\(=\left(x^2+x+1\right)^2-3\left(x^2+x+1\right)+7\left(x^2+x+1\right)-21\)
\(=\left(x^2+x+1\right)\left(x^2+x-2\right)+7\left(x^2+x-2\right)\)
\(=\left(x^2+x-2\right)\left(x^2+x+8\right)\)
\(=\left(x-1\right)\left(x-2\right)\left(x^2+x+8\right)\)
\(\left(x^2+x+1\right)\left(x^2+x+5\right)-21\)
\(=\left(x^2+x\right)^2+6\left(x^2+x\right)+5-21\)
\(=\left(x^2+x\right)^2+6\left(x^2+x\right)-16\)
\(=\left(x^2+x+8\right)\left(x^2+x-2\right)\)
\(=\left(x^2+x+8\right)\left(x+2\right)\left(x-1\right)\)