It's related several physical parameters, and thus, ultimately to some quantum mechanics concepts, I don't remember the exact one's off the top of my head.
In general, as temperature increases for a given substance, viscosity decreases. A great example is glass. At high temperatures when it is workable, glass has a relatively low viscocity but at room temperature it's viscosity is huge (something around the area of 10^35 poise IIRC).
Larger molecules usually have higher viscosity's than analogous smaller molecules. For example, propanol's viscocity is greater than ethanol's which is greater than methanol's.
Generally, the strength of a substance's intermolecular bonds determines its viscosity.
The stronger these bonds are, the more viscuous your substance will likely be.
(Other factors include temperature, pressure, state, etc...)