I know what each rating means, but how does the MPAA decide what rating to give a movie?
Nobody outside the MPAA really knows for sure. There are some general rules that filmmakers follow, depending on what kind of rating they want to go for. A movie can change from PG to PG-13 if it uses a swear word like 'fuck' more than once; some scenes of violence have to be toned down to get a rating of NC-17 (which is considered the rating of death for filmmakers, as almost no major movie theater chain will run an NC-17 movie and video stores like Blockbuster refuse to shelve such movies) down to an R rating (or sometimes referred to as a 'hard R' rating).
The Wikipedia article on ratings gives a general outline of how ratings are given. Roger Ebert gave a stinging criticism about how the MPAA goes about giving its rating system (it makes you think that not much has changed since the days of The Hays Office - with a nice gag against the Hays Office in a 1942 cartoon), and this article from 2007 shows that while the studios recognize films as a 'Hard R', it takes a LONG time for the MPAA to come around and make a new rating reflecting this.
The MPAA is made up of a group of people that are not connected to the movie industry, overseen by Joan Graves, that make their decisions based on a predetermined 'list' of acceptable and unacceptable behaviors/language.(This wiki-link to the guidelines touches upon the list of acceptable content)
According to the MPAA website, these ratings are in place to 'safeguard artistic freedom', but critics of the rating system argue that the decisions are made with morality in mind rather than artistry.
I strongly recommend finding a copy of This Film Is Not Yet Rated, a disturbingly funny documentary that thoroughly digs into the process.
I know it's a different system, but there was a fascinating interview with the head of the BBFC (the British equivalent of the MPAA) on BBC radio last week. The complete programme is available to download as a podcast.
He explains that they have certain rules of thumb (e.g. no more than 4 uses of the F-word in a 12A - roughly equivalent to PG-13), but that these are only guidelines and can be broken (most recently in the case of The King's Speech which was rated 12A despite lots of uses of the F-word in the speech therapy scenes). He also explains why the BBFC initially rejected Human Centipede 2, saying the were unable to pass it even with cuts, but subsequently reconsidered it after the distributor made cuts and resubmitted the film.
So generally (in Britain at least) it comes down to a mixture of fairly strong (but not rigid) guidelines and subjective judgment.