For a more general analysis of the lore behind each class, see:
Warriors: Many races have some form of army, so it is natural for warriors to be playable.
Rogues: Nearly all races have rogues because there are always spies and thieves among the populace.
Priest: Humans have long followed the Holy Light, and it plays a major role in their society. Priests exist to guide their people in the ways of the Light.
Paladin: Human priests and knights founded the original order of Paladins, the Silver Hand, during the Second War. Though the Hand suffered greatly during the Third War, Paladins still fight on in the defense of humanity.
Mage: During the war with the trolls, prior to the orc's arrival via the Dark Portal, high elven mages agreed to teach one hundred humans the arcane secrets of magic. After the war had been won, the humans and small number of high elves founded the Mageocracy of Dalaran. Dalaran fell soon after the start of the Third War, but by that time, mages had spread to human cities all over Azeroth.
Warlock: Though frowned upon by society, many mages have turned to demonic magic in pursuit of knowledge, power or revenge against the Legion.
Paladins and Priests: The dwarves were introduced to the Holy Light by humans and have adopted it as their religion. After the Third War, the humans began allowing dwarves into the Knights of the Silver Hand to repopulate the shattered order.
Hunters: The dwarves have long been renowned for their brilliant marksmanship and skill with guns. In recent times, the foundation of an Explorers' League has spread dwarven adventurers all across the globe.
Mage: With their intuitive and curious minds, the gnomes have great interest in all the sciences of Azeroth, and the arcane is no exception.
Warlock: In the same way as humans became warlocks, sometimes a gnome's pursuit of knowledge leads them down more dangerous paths of magical study.
Druids: After the destruction of the Well of Eternity the night elves turned away from the use of the arcane and became wardens of the world they had almost destroyed. The druids were led by Cenarius's first night elf student, Malfurion Stormrage. The druid order was made only of males until the end of the 3rd War. The loss of druids during that war has led to some females entering the fold.
Hunter: Being defenders of nature, the elves are keen hunters. The closeness to nature which the night elves cultivate gives them a strong bond to animals, and elven archers have long defended Ashenvale from enemy invaders.
Priest: The night elves worship the Moon Goddess, Elune. The Priestesses of Elune have recently begun accepting males, just as the druids have with females.
Priests and Paladins: Having been taught the ways of the Holy Light from the naaru, the draenei are a very religious race and priests are very important to them. They have long employed holy warriors in their fight against the Legion. Amongst the draenei, Priests and Paladins are known as Anchorites and Vindicators, respectively.
Mage: The draenei/eredar are extremely intelligent and have a natural affinity for magic in all its myriad forms (according to the official Burning Crusade website).
Hunters: Being feral in nature, the orcs are natural hunters. The shamanistic culture the orcs practiced before the demons included the practice of taking on animals as life long companions.
Shaman: Having returned to their shamanistic roots, the orcs are important shamans of the New Horde. Thrall used his powers as a Shaman to revitalize the orcs after they were all but lost to the demon taint.
Warlock: A few orc warlocks pledge themselves to Thrall and the New Horde. Many of these warlocks still work for the Shadow Council or one of its sub-organizations, such as the Burning Blade, but some are genuinely loyal to Thrall. They are constantly being watched by Thrall's suspecting eyes.
Druid: Being in tune with nature and their Earthmother, the tauren are very druidic. Now that the night elves have come out from their centuries of hiding, the tauren have been re-exposed to druidic powers. They had practiced the druidic arts side by side with night elves during the War of the Ancients but it had fallen out of practice.
Hunter: Hunters play an important role in tauren society, both for keeping the tribe sustained and in following the sacred rites of the Great Hunt.
Shaman: With their spirit walkers and nature/totem-based religious practices, Tauren make ideal candidates for the way of the Shaman.
Hunter: Trolls are well known and respected for their prowess as hunters.
Priest: The trolls worship their primal Loa Gods. Troll priests are feared for their voodoo hexes. Vol'jin, leader of the Darkspear tribe of trolls that joined the Horde, is a Shadow Hunter.
Mage: The trolls have faced major defeats at the hand of mages twice in history. A cunning and adaptable race, they have since shown a talent for the Arcane Arts themselves.
Shaman: Before joining the Horde they were witch doctors who excelled in the powers of the wards and alchemy study, so a kind of shaman has always existed among the trolls, but only recently have the trolls begun to study the shamanistic arts, which they were taught by the orcs, and in conjunction with their voodoo magics trolls make up the Shaman class quite well, and are teaching their arts to other trolls and orcs as well.
The undead retain whatever Class they were from life, so undead can be any class humans can be. Paladins, however, are immune to the plague and therefore none became Undead unless infected willingly.
Priests: Most of the undead have abandoned the Light, which has seemingly abandoned them. Many Forsaken now follow the Shadow, a twisted reinterpretation of the Light, one that supports ruthless pursuit of power.
Paladin: See Blood Knight.
Priests: Though the elves have suffered much since they first adopted the way of the Light from humans, a number are still faithful to the true ideals of their religion.
Mage: They have been natural spellcasters since they were Highborne.
Warlock: The blood elves have turned to the Burning Legion as a method of obtaining mystical energy, as can be seen by the massive demonic crystals in their towns. The path of the Warlock is simply another way of harnessing the demonic forces.