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?
What you ask happens exactly when $K$ is infinite. If $K=\Bbb F_q$ is finite, just take $\prod_{a\in K} (x_1-a)$ which vanishes on every element of $\Bbb F_q^n$ but not on $(b,0,\cdots,0)$ where $b\in\Bbb F_{q^2}\setminus\Bbb F_q$. If $K$ is infinite, you may prove by induction that the only polynomial which is zero on all of $K^n$ is zero: write $p(x_0,\cdots,x_n)$ as a polynomial in $x_n$ with coefficients in $K[x_0,\cdots,x_n]$, then see that if there's any point $(a_1,\cdots,a_{n-1})$ so that the coefficients don't all vanish we have $p$ has only finitely many roots of the form $(a_1,\cdots,a_{n-1},b)$ as $b$ varies. So all the coefficients must vanish, and eventually you're reduced to the case of polynomials in $K[x]$ vanishing at all elements of $K$: but every polynomial in one variable has finitely many roots over a field.
The geometric interpretation is that the points $K^n\subset \operatorname{Spec} K[x_1,\cdots,x_n]$ are dense iff $K$ is infinite.