Anime Hair colors can run the entire spectrum and then some, only limiting themselves to the "natural" range in the most serious of series. One reason, it is claimed, is that it helps the viewer distinguish characters who might otherwise be hard to tell apart in a show with budget-saving simple designs. This in turn makes the character more easily copyrightable. Subtler variations of the hair could work, but these are usually avoided because they are difficult to animate.
Beyond that, though, there does seem to be a rough correspondence between hair color and personality type, although the exact details are debated among fans and nothing seems to be 100% consistent from show to show — or even within a show.
A quick Google search will turn up at least several dozen pages discussing the topic, with most of them disagreeing in varying degrees with each other. Basically, anything found on this topic — especially the notes below — is nothing more than a broad generalization that can be contradicted freely by any given show.
In general, though, brown, black, or (rarely) naturalistic auburn hair tends to indicate an Ordinary High-School Student or some other "grounded", "normal" (Japanese) person. Brown hair, in particular, tend to be the most widely used color for ordinary Japanese characters, including the main characters, because a black-haired female can indicate other qualities. Black hair (or dark blue and purple) can be more common among male protagonists, to make them more relatable to the audience. In some anime, green hair can serve as an additional "standard" hair color (for instance, Midori in Midori Days or the ever-popular My Hero Academia protagonist Izuku "Deku" Midoriya).
A blonde woman is often either The Ditz or a callous, selfish manipulator. (Female blonde Japanese characters, particularly very tan ones, also evoke the "kogal" and "yamanba" youth subcultures, which while more or less harmless are considered extreme almost to the point of delinquency.) There are frequent exceptions, though, such as Kaolla Suu from Love Hina. Often, blondes also have some kind of foreign ancestry, typically American or European. (For instance, Rebecca Miyamoto from Pani Poni Dash!, and Kaolla Suu, who is herself from a fictional island nation.)
Blond hair on a male character may imply that he is The Trickster. Alternately, it may symbolize that this character is a focus of chaos, and trouble follows him wherever he goes, such as Vash the Stampede from Trigun, or Soichiro Nagi from Tenjho Tenge; a live-action example is the movie version of Battle Royale's Kazuo Kiriyama. It is also not uncommon for anime males with long blond hair to be portrayed as Casanova-types. (Examples: Kurz from Full Metal Panic!, Allen Schezar from The Vision of Escaflowne, Kyle from Suikoden V among others...)
Red hair often corresponds either to spirit possession and/or enchantment (as in Ranma's red-headed "curse form"), or to the more Western "hot head" stereotype (such as Asuka from Neon Genesis Evangelion or Lina Inverse from Slayers).
White hair tends to indicate dignity and skill (or simply obvious age), unless the character in question is a Bishōnen, in which case he is almost always a villain. If the character is a white-haired, dark-skinned woman, then dignity, skill, or power is often implied, but the character is often also emotionally driven and portrayed as a "force of nature". Urd from Ah! My Goddess, Sanae from Hanaukyō Maid Team, and Sara from Hand Maid May are good examples. Storm of the X-Men is a good Western example.
Blue hair on a woman tends to indicate shyness or introversion, a correspondence which seems to have originated with Ami "Sailor Mercury" Mizuno from Sailor Moon and taken off with Rei Ayanami from Neon Genesis Evangelion in such a way she named a whole trope based on the resulting archetype (even though not all examples therein have necessarily blue hair). It also seems to connote extraordinary intelligence in both genders — Ami Mizuno, again, but also Miki Kaoru from Revolutionary Girl Utena and Touma Hashiba from Ronin Warriors.
Pink hair tends to indicate kindness and cheerful innocence, especially on girls. Examples of such can be found with Miyuki from Lucky Star, Ribbon from Kirby 64: The Crystal Shards, and pretty much every Pink Heroine in the Magical Girl genre.
In console RPGs, blue, aqua, or green hair on either gender is a common indicator that the character is a spellcaster or has magical powers, often for hereditary reasons. See Rydia from Final Fantasy IV, Terra from Final Fantasy VI (at least in the sprite art), any Ryu from any Breath of Fire game, Rena and Leon from Star Ocean: The Second Story, and many others.
The list could go on, but as noted above, the assignments are extremely subjective. Sometimes they're weird for the sake of weird. It may also change with just a trip across the sea.
Don't confuse exotic hair colors with lighting and shading effects, though. It's common in commercial four-color art and in animation to use dark blue as a highlight color for black hair; just look at any Superman comic. However, this practice has many fans who insist that black-haired Akane Tendo from Ranma ½ has blue-black or even blue hair. Similarly, the purple shades in the hair of Faye Valentine (Cowboy Bebop), Rei Hino (Sailor Moon) or Misato Katsuragi (Neon Genesis Evangelion) may be an artistic license for simple highlights, especially given that in their respective manga, all three have jet-black hair.
Similarly, it's not uncommon to find hair, eye, and skin colors all shifted when the characters are under special lighting conditions, such as red/golden sunrises and sunsets. The resulting colors are just what happens when hair color and tinted light mix.
As a side note, be aware that a character's hair color sometimes changes radically during the transition from manga to anime. While the anime version of Ranma's girl-form is a redhead, the manga version has black hair and is able to masquerade as a regular Japanese girl without a wig or hair dye (though Takahashi played with this and drew her with different-colored hair on the times when it was colored, but used red more frequently later on). Similarly, Shampoo from the same series has bright purple hair in the anime, whereas in the manga, it was limited to subtle purple highlights (see the above discussion about those). Utena Tenjou (from Revolutionary Girl Utena) was originally a blonde, but in the leap to anime, her hair acquired the pink color of her uniform (which itself changed color to a deep blue).
Such changes don't always have an implied meaning, as they might for a character created for an anime. Allegedly this makes characters more easily identifiable from each other when you have a large cast outside of black and white art. (The huge cast of Negima! Magister Negi Magi is a notable victim of this, although to be fair many of their hair colors were established by the creator in the color covers for the tankoubon releases of the manga.)
Note also that in recent series, eye colors have been starting to get "non-traditional" as well. Originally, red, yellow or purple eyes usually meant non-human origins. This is no longer always the case.
Unusual hair colors are usually ignored unless the hair color is intended to be seen as strange and set the character apart from their peers. For example, Bleach's main character, Ichigo, has naturally light hair, which many people incorrectly presume to be the result of bleach and a sign of delinquency. (Ironically not the reason for the series name, according to an interview with the mangaka in an issue of Shounen Jump.) In the same series, Orihime recalls having been picked on by older girls for having similar natural orange hair. Rangiku's blonde hair, Renji's red hair, and Hitsugaya's silver hair have also drawn comments. The heroine of The Twelve Kingdoms has distinct, naturally red hair that sets her up for ridicule by her peers, who think she dyed it, and her parents, who demand that she dye her hair a normal color.
Most of the time, however, if hair color is an issue, it's to indicate that somebody is actively fighting convention and thus, a delinquent (for example, Onizuka from Great Teacher Onizuka). In some cases, this causes a bizarre cross-talk, such as in Excel Saga, where characters with blue, purple, and pink hair pass without comment, but bleached-blond gang members are immediately recognized for what they are. Another example of this can be seen in This Ugly Yet Beautiful World, where one of the ginger-haired alien girls (whilst standing next to her green-haired co-star) is rebuked by a teacher for having a "non-natural" hair color.
(In the case of Truth in Television, recent news reports from Japan have cited cases of school administrators who have insisted that all their students have only black hair, and enforce mandatory dyeing on those without it, using draconian regulations and punishments.)
Beginning in 2000 or so, Magical Girl alter egos tend to have different shades than their natural hair color. Tokyo Mew Mew is one of the most notable examples but not the earliest, although originally in the manga, the characters kept their hair colors; only once the anime began and gave them different shades did the manga follow suit. (The mangaka also did this with the transformation phrases, previously not present, as well as the altered weapons.) One of, if not the earliest hair color changes was actually Phantom Thief Jeanne. Pretty Cure, in particular, ran with this starting in Yes! Pretty Cure 5 — the Cures usually have unnatural hair colors even in their civilian forms, which become even more vibrant shades once they transform.
Sailor Moon, on the other hand, played it backwards. Covers and colored pages of the manga often showed the Senshi with wild hair colors even when not transformed, but The '90s anime gave them more natural hair in both forms, Usagi and Minako's blondness notwithstanding. Pretty Guardian Sailor Moon, the tokusatsu adaptation, only gave the Senshi their original hair colors when transformed, and they otherwise had standard shades of brown and black.
The bizarre hair colors seen in modern anime have their origins in the black-and-white manga source material. In a nation where virtually everyone has black hair, characters in manga (who often had very similar facial features as well) could be difficult to distinguish from one another. One solution was to give them different hairstyles or to use variant shading (or no shading at all) on their hair. When the mangas were translated to color animation, the odd shadings were sometimes translated as bright colors. This trope/concept particularly exploded, however, with the advent of computer video games in the 1980s - due to palette restrictions, giving characters "natural" hair colors, black especially, that read well on-screen was often enormously difficult. Bright hair colors in the red, blue, purple, and green ranges, however, often translated very well to the screen and often made it easier to track characters visually on screen. And given the cross-promotion and cross-inspiration between anime and video games, even in the 80s, the concept transferred very quickly.
In most cases, these unnatural colors are understood to be normal, natural shades by the other characters. That is to say, the color carries none of the social connotations it would in the real world, and other characters rarely if ever react to it as unusual in any way. This may indicate that the color used is more a visual shortcut than a real color - e.g., perhaps the cast of Ranma does in fact have black hair, but, just as their eyes are drawn nothing like real eyes, their hair gets drawn nothing like their "real" hair. Dark blue hair, in particular, is often understood to be a "stylized" black, used in instances where actual black hair simply would not read well visually.
Can also be used to indicate which are the "important" characters in a cast. For instance, in Vampire Knight the anime, all of the vampires have unusual hair colors—at least three blonds and four with white hair, and ironically the main father figure-like vampire has black hair, while every human girl has brown hair. Apparently, turning into a bloodsucker merits a major trip to the salon?