How much can two polynomials agree on?
In the following, when we write $\dim$, we mean dimension as a topological space, and when we write varieties, we mean schemes of finite type over a field, and when we write $\dim$ of a scheme, we mean dimension of the associated topological space.
Let $U\subset X(\Bbb R)$ be the open set on which $f$ vanishes. $f=0$ is a closed set in $X$, so if $X$ is reduced and $U$ is of dimension $\dim X$, then $f$ must be identically zero ($\{f=0\}$ is a closed set containing $U$, so $\dim \{f=0\} \geq \dim U=\dim X$, and the only closed subset of an irreducible, reduced variety of dimension $\dim X$ is $X$).
It is important that $\dim U = \dim X$: it may happen that $\dim U < \dim X$, such as the case when $X = V(x^2-y^2z)$ - here, $X$ is two-dimensional, irreducible, and reduced, but it is possible to pick a $U\subset X(\Bbb R)$ which is open but has dimension 1: consider $X(\Bbb R)\cap ((-1,1)\times(-1,1)\times(-2,-1)).$ If $U$ consists entirely of smooth points, you are ensured that $\dim U=\dim X$, by the implicit function theorem.