#2
It can't be explained in a short answer. There's many rules. Do you know about the different motions and about consonances and dissonances? That'd be a good place to start.

EDIT: http://www.listeningarts.com/music/general_theory/species/menu.htm