In general, if $K$ is a field, it could be that exists $f(x)\in K[x]$ such that $f(a)=0$ for all $a\in K$; for example, set $K:=\mathbb Z/(2)$ and $f(x):=x^2+x$.
Now, if $f(x)$ vanishes on all $\operatorname{Spec} K[x]$, it means that $f(x)\in \mathfrak p$ for all $\mathfrak p\subset K[x]$, so that $f(x)$ is nilpotent. However $1$ is clearly not nilpotent. Is this because the sets $\operatorname{Spec} K[x]\neq K$ in general, and the fact that $f$ vanishes on all $K$ only means that $f$ belongs to the (always maximal) ideals of the form $(x+a)$ for $a\in K$? That would make sense to me, in fact in the example above $x^2+x$ belongs to both $(x)$ and $(x+1)$.
So is there any characterization of the fields $K$ for which, if $f\in K[x_1,\dots ,x_n]$ vanishes on all $K^n$, it vanishes on $\operatorname {Max Spec}K[x_1,\dots ,x_n]$? For example if $K$ is algebraically closed and $n=1$, then as sets $\operatorname{Max Spec}K[x_1]=K$. However this already isn't true anymore for $n\gt 1$ or if $K$ is not algebraically closed. For example, are there any polynomials in $\mathbb R[x]$ belonging to all the ideals of the form $(x-a)$ but not in $x^2+1$? What is the geometric interpretation of this fact, if there is any?