Purpose of defining regular functions Let's first consider the case of affine variety which is defined by a zero locus of some polynomials in $\mathbb{A}^n$. Morphisms (regular maps) between two affine variety are just restriction on polynomial maps. But when we restrict to an (Zariski) open subset of the variety, we can define more functions, i.e. quotients of some polynomials with nonzero denominator.
My question is why aren't we happy to define only polynomial maps even on each open subset?
Now consider the projective case. First, the same question arises: why do we need quotients of polynomials? And why do we require the polynomial of the same degree?
 A: When we study a family of objects we are more interested on the category that it will define (with the corresponding morphisms) and how this objects are related, equivalence classes that preserve some properties, and others categories that help us to study the main objects, for instance, the coordinate ring of a affine variety.
The study of affine varieties in the classical sense, is the study of the zero locus of a family of polynomials defined on $\mathbb{A}^n$, they are closed sets on the Zariski topology. So, why study open subsets? This arise from the study of quasi-projective varieties, but algo by the localization on a point which is of interest for defining the tangent space (that leads to the understanding of the singularities of a variety for example). So, let's see an example. Consider the affine variety $C$ defined by $y^2=x^3+x^2$ (draw it) with coordinate ring $k[C]=k[x,y]/(y^2-x^3-x^2)$. We want to identify the dimension of the tangent space in the origin $p=(0,0)$. This is the dimension of the $k$-vector space $m_p/m_p^2$,where $m_p$ is the maximal ideal associated to the point $p$ on the local ring $\mathcal{O}_{X,p}$ which in the case of affine varieties is isomorphic to $\left(k[x,y]/(y^2-x^3-x^2)\right)_{m_p}$ this is:
$$\mathcal{O}_{X,p}\simeq \left\lbrace \frac{f}{g}:f,g\in k[C], g(p)\neq 0\right\rbrace$$
 (so we get functions that are not polynomials) if $\dim_k m_p/m_p^2=2$ it will be a singular point. So we work out this.
Another example. We want to prove that $\mathbb{A}^2\setminus\{0\}$ is nor an affine variety (this is, not isomorphic to a closet subset of an affine space). You will require in an elemental proof the computing of the ring $k[D(x)]$ which is the coordinate ring associated to the open set $D(x)=\left\lbrace (x,y):x\neq 0\right\rbrace$ (in general $D(f)=\left\lbrace (x,y):f(x,y)\neq 0\right\rbrace$) which is the ring $k[x,y][x^{-1}]$ that is a localization, this gives us functions that are not polynomials (If you want the elemental proof, I can edit and post it).
Now, for the projective space, I will simply consider $P=\mathbb{P}^n$. We want some razonable functions from $P$ to $k$, so if we consider a polynomial function as $[x_0:\cdots:x_n]=[\lambda x_0:\cdots:\lambda x_n]$, for all $\lambda\neq 0$ in the field. We need that such polynomial, say $F$, must satisfy the following condition:
$$F(x_0,\cdots,x_n)=F(\lambda x_0,\cdots,\lambda x_n)$$
for all $\lambda\neq0 $ in the field. This is hard to achieve, if we study this a little, we will get that $F$ must be a constant. So our ring give us no information. So we need other tool (ring), and we note that if we just try by taking fractions of polynomials, we have a chance, doing this, we need a similar condition as before, say
$$\frac{F(x_0,\ldots,x_n)}{G(x_0,\ldots,x_n)}=\frac{F(\lambda x_0,\ldots,\lambda x_n)}{G(\lambda x_0,\ldots,\lambda x_n)}$$
for all $\lambda\neq 0$ in $k$. This will be well defined if both polynomials are homogeneous, and we note that they will be of the same degree. For example, taking $\mathbb{P}^1$: Let $F,G$ two polynomials such that satisfies
$$\frac{F(x_0,x_1)}{G(x_0,x_1)}=\frac{F(\lambda x_0,\lambda x_1)}{G(\lambda x_0,\lambda x_1)},$$
compute a general case, and you will note that both polynomials must have the same degree and each of its monomials of the same degree. If you have trouble, simply note that if you take this polynomials to be homogeneous (anyway, they are the only ones that have sense in this case), then 
$$\frac{F(\lambda x_0,\lambda x_1)}{G(\lambda x_0,\lambda x_1)}=\frac{\lambda^d F(x_0,x_1)}{\lambda^b G(x_0,x_1)}=\frac{F(\lambda x_0,\lambda x_1)}{G(\lambda x_0,\lambda x_1)}$$
so that, $d=b$, hence they hace the same degree. 
