Farming in the original sense of the word means to do nothing but killing a certain type of monster for the express purpose of getting them to drop certain items. It is distinct from grinding experience, as monsters will continue to drop items regardless of the player's level. The term is also extended to include searching for ore and herbs, which does not have to involve killing mobs.
It is common for tailors to kill lots of cloth-dropping humanoids to get cloth or for leatherworkers to farm beasts for leather. Players may also repeatedly kill certain elite mobs in instances known to drop good items.
Many quests involve farming, for example, killing kobolds in order to get their candles (Quest:Kobold_Candles). Building reputation with certain factions also usually involves farming certain mobs. Timbermaw Hold, Argent Dawn, and Cenarion Circle are good examples.
A secondary meaning of the term is "collecting any crafting material" (e.g. herbs or ore). Although this activity does not necessarily involve fighting mobs, many players feel that it's similarly repetitive and uneventful as farming mobs.
Some players use the expression "farming the auction house" jokingly, meaning one of two things — either they buy needed items (instead of really farming them) or they earn gold in the AH (by buying low and selling high).