The function field of $X$ is made up of rational functions defined on $X$. So we consider only quotients of polynomials, because we want rational functions and not arbitrary functions in general. Besides we want to consider equal two polynomial quotients $p/q$ and p'/q' if they are equal if restricted to $X$, i.e. if $f$ divides pq' - p' q.
More formally, suppose $k$ is an algebraically closed field and consider a closed irreducible subvariety $X$ of $\mathbb{A}^n_k = k^n$. The ideal of $X$ is the ideal $I(X) \subseteq k[x_1, \dots, x_n ]$ made up of polynomials that vanish on $X$. The ideal $I(X)$ is prime since $X$ is irreducible. A regular function on $X$ is a function $f \colon X \to k$ such that there exists a polynomial $P \in k[x_1, \dots, x_n]$ such that $f(x) = P(x)$ for all $x \in X$. It is quite clear that the set $k[X]$ of regular functions on $X$ is a $k$-algebra and $k[X] = k[x_1, \dots, x_n] / I(X)$. Hence $k[X]$ is a domain. The field of quotients $k(X)$ of $k[X]$ is the field of rational functions of $X$. So $k(X)$ is made up of quotients $P/Q$, where $P$ and $Q$ are polynomials, under the equivalence $\equiv$ defined by: P/Q \equiv P' / Q' if and only if P Q' - P' Q \in I(X).
In your case, $X$ is defined by $f = 0$, where $f$ is an irreducible polynomial. Nullstellensatz implies $I(X) = (f)$.
There exist generalizations. After defining what a regular function on a quasi-projective variety is, we can easily define the field of rational functions of an irreducibile quasi-projective variety. In scheme theory, a rational function on an integral scheme $X$ is an element of the stalk of the generic point. These two construction are particular cases of the following: if $X$ is an irreducible topological space, the set of nonempty open subsets is direct, thus if we have a sheaf $F$ of abelian groups on $X$ we can costruct $\lim_{\to} F(U)$, where the limit is over nonempty subsets $U \subseteq X$.