Substitution reactions, nucleophiles and leaving groups

The reactions below are examples of nucleophilic substitution reactions.
In substitution reactions the parts of two reagents are exchanged.

hydroxide anion  + CH3–Br HO–CH3(alcohol) + 
ammonia* 2H3N: + CH3–Cl H2N–CH3(amine) +  + NH4+
cyanide anion :N≡C: + CH3–I  :N≡C–CH3(nitrile) +
*This reaction requires a second mole of ammonia to react with the HCl released.

Substitution at a saturated carbon by a nucleophile may occur if the carbon bears a good leaving group.  

Good leaving groups are stable anions or small molecules.
Better leaving groups are weaker bases (better able to bear negative charge).  

The halide ions Cl, Br and I are very weak bases due to being the conjugate of the strong acids HCl, HBr and HI.  

The relative rates of reaction of the halides (Cl< Br < I ) is due to the C-X bond strength being highest for chlorides.  
The high C-F bond strength is the reason that fluoride is NOT a good leaving group.

Nucleophiles that react by substitution have an atom with non-bonding electron pairs. One of these is bonding in the substitution product.