Prove that $\cos(\pi/7)$ is root of equation $8x^3-4x^2-4x+1=0$
Put $2x=z+\dfrac1z$ in $$(2x)^3-(2x)^2-2(2x)+1=0$$
and multiply by $z+1$ to find $z^7+1=0$ whose roots are are $e^{(2k+1)\pi i/7}$ where $k\equiv0,\pm1,\pm2,\pm3\pmod7$
So, the roots of $$\dfrac{z^7+1}{z+1}=0$$ are $e^{(2k+1)\pi i/7}$ where $k\equiv0,\pm1,\pm2,3\pmod7$
Finally $2\cos y=e^{iy}+e^{-iy}$
$$ \cos\frac{2\pi}{7}+\cos\frac{4\pi}{7}+\cos\frac{6\pi}{7}=\frac{2\sin\frac{\pi}{7}\cos\frac{2\pi}{7}+2\sin\frac{\pi}{7}\cos\frac{4\pi}{7}+2\sin\frac{\pi}{7}\cos\frac{6\pi}{7}}{2\sin\frac{\pi}{7}}= $$ $$ =\frac{\sin\frac{3\pi}{7}-\sin\frac{\pi}{7}+\sin\frac{5\pi}{7}-\sin\frac{3\pi}{7}+\sin\frac{7\pi}{7}-\sin\frac{5\pi}{7}}{2\sin\frac{\pi}{7}}=-\frac{1}{2}. $$ Let $\cos\frac{\pi}{7}=x$.
Hence, $$2x^2-(4x^3-3x)-x=-\frac{1}{2},$$ which gives your equation.
We have $$ \cos{2\theta} = 2\cos^2{\theta}-1 \\ \cos{3\theta} = \cos{\theta}(2\cos^2{\theta}-1) - 2\sin^2{\theta}\cos{\theta} = 4\cos^3{\theta}-3\cos{\theta}, $$ so $$ \cos^2{\theta} = \frac{1}{2}(\cos{2\theta}+1) \\ \cos^3{\theta} = \frac{1}{4}(\cos{3\theta}+3\cos{\theta}) $$
Putting these into the equation gives $$ 8\cos^{3}{\theta}-4\cos^2{\theta}-4\cos{\theta}+1 \\ = 2\cos{3\theta}+6\cos{\theta} -2\cos{2\theta}-2-4\cos{\theta}+1 \\ = -1+2(\cos{3\theta}-\cos{2\theta}+\cos{\theta}) = \frac{\cos{(7x/2)}}{\cos{(x/2)}}, $$ the last part of which comes from the formula $$ \sum_{k=-n}^n (-1)^k \cos{kx} = (-1)^n \frac{\cos{(n+1/2)x}}{\cos{(x/2)}}, $$ which can be proven by induction. It's then clear that this is zero if $x$ is a zero of $\cos{(7x/2)}$, but not $\cos{(x/2)}$, and the first one of these is $\theta=\pi/7$.