Why use different airfoils on the same wing of an aircraft?
Because the wind tunnel has determined what the best airfoil is, at this particular span, over the whole operational range of flight:


Stall speed: docile pre-stall behaviour with outboard wing stalling last to retain roll control.
Landing speed with flaps &amp; slats out: high stall angle, high $C_L$
Climb speed: low drag in high lift conditions. 
Cruise speed in clean configuration: low drag, low pitching moment, high drag/lift divergence speeds.


The design goal is the performance of the total wing, wing profile is one of the parameters that can be used to optimise performance, minimise drag, provide good structural characteristics, and provide a large volume for the on-board fuel.


For the wing root, the aerofoil must have a good cantilever ratio (thickness) for torsional and bending stiffness.
For the wing inboard section with flaps extended, aerofoil drag must be low in high lift conditions. 
For the wing tip, the aerofoil must have a high maximum $C_L$ and gradual stall characteristics)
For all wing sections, the aerofoil must have a sufficiently high critical Mach number.
For all wing sections, pitching moment coefficient should be low to moderate, to avoid high trim drag, and high torsion at high dynamic pressure.
For all wing sections, aerofoils must not be extremely sensitive to manufacturing tolerances, dirt/bug build-up etc.


So different bits of wing have different design characteristics. The whole wing is a gradually blending unit of different aerofoils.