To add just a little bit to Martin's already excellent answer.
Philosophically, we like the following idea: given a space $X$, we can learn a lot from $X$ by a ring of functions on this space. However, the whole ring loses a ton of information. So instead, lets remember what happens locally: so we get a sheaf of functions on a space.
Now given a ring $R$, we do the math-y thing and reverse the above construction. We want a space $X$ on which $R$ is the ring of functions. We want it to be as natural a construction as possible. Grothendieck's insight was that the "set of prime ideals" forms a good "set of points of a space" to do geometry. Again though, if we only remember the global information, we lose a huge amount of information that is intrinsically.
So working with $Spec(R)$ and the ring of functions $R$ gives you natural motivation to not only study a ring, but all its quotients (functions on closed sets) and all its localizations (functions on open sets) at once.
Why localization? It really comes down to what localization does to the behaviour under localization of the lattice of prime ideals. Think first about the process of passing from $R$ to $R/I$ for some ideal $I$. What are the prime ideals in $R/I$ - they are those prime ideals of $R$ containing $I$. Containing a prime ideal is what we take to be "vanish at that point". This is the key idea: the property of containing a prime ideal is the right replacement for vanishing in the classical setting.
It is a good idea to take a good look at the Nullstellensatz, and extract the above statement in the classical setting.
Now why localization? In a similar manner to the above discussion, the prime ideals that survive localization are the ones that dont intersect the set that you are inverting. If you want to think about a single function $f$, then localizing at $f$ to get $R_f$ this tells us that the prime ideals of the localization are (more precisely, correspond to) those in $R$ which do not contain $f$: i.e. the set of points where $f$ doesnt vanish.
One should write down and chase the appropriate diagrams to make sure that the "correspondence between prime ideals" for the two cases I mentioned above are functorial, that they behave well with morphisms, but thats the intuition.