There are multiple reasons:
If you use raw manure next to leafy plants or on root crops, you risk bacteria moving from the manure onto your food. E. coli isn't something you want on your food.
Chicken and bat manures are high in nitrogen. It's intense enough to burn your plants.
It can stink. If you dump a bunch of raw cow manure into a flower garden under your front window, your living room or front porch aren't going to be pleasant places to hang out.
The rotting/composting process allows a variety of little organisms to convert the nutrients in the manure into forms that are usable by the plants.
It's not really a blanket prohibition against using raw manures on any plants. I mix regular garden and kitchen wastes into my horse manure piles, and the cucumber and pumpkin volunteers from the kitchen waste thrive in the not-very-well-rotted manure. So I'm guessing that dumping a little semi-raw horse manure on those plants won't hurt.
As for length of time, it depends on several things:
- the animal (different animal manures have different carbon-to-nitrogen ratios)
- bedding (which alters the C:N ratio)
- size of pile
- whether the pile is aerated regularly
- whether the pile is wet or dry
It's basically a composting process, so these are the same considerations you'd have for a compost pile.
I turn my horse manure piles regularly (I'm a compulsive composter) and they're pretty well cured within about 6 months. Unturned it can take a year or more. If we used different stall bedding it might take more or less time. If I wasn't mixing in chicken manure it would probably take longer (chicken manure adds more nitrogen and speeds things up). But if it was just a big pile of chicken manure, the chemistry works against you: too much nitrogen. Adding some carbon (leaves, wood chips, etc) would balance it out.