Why do we still use pilots to fly airplanes?
That's a good question, and brings up a joke that many pilots know well:


  "What's going to be in the cockpit of the future?"
  
  "A dog and a pilot."
  
  "A dog?  Why a dog?"
  
  "Well, the dog is there to keep the pilot from touching anything."
  
  "Ummm, why have the pilot then?"
  
  "Well, someone has to feed the dog! "


Technology has improved to the point where airplanes can pretty much fly and even land themselves.  They are even getting pretty good at handling "normal" emergencies like engine failures and depressurizations.

Where pilots really shine though are the type of abnormal and emergency situations that aren't "in the book".  

When an engine flies apart and shreds the hydraulic lines on all three redundant hydraulic systems, a computer will be out of options because it was never programmed to handle that (because it was considered "virtually impossible" when it was designed).  A pilot on the other hand can analyze and experiment until he finds enough of a solution to keep the airplane in the air as he works through other issues.

During a total electrical failure, the computers won't be much good.  Sure, you can design redundant systems and make it so that it "can never happen", but what about when it does?

There are also all of the little things that a pilot is constantly making decisions on how to handle.  Some examples could include:


Can the airplane fly with a particular feature inoperative?  
What about multiple features inoperative?  
How do they interact with each other?  
What do you do when the passengers take too long to board and you are going to miss your departure slot?  
What do you do when the ground crew forgets to close a door?  
What about when the tug driver doesn't push you back quite far enough?  
Or ATC wants to change you to a different runway?  
Or you ask ATC to change you to a different runway because it might save a few minutes and that will keep you from having to deice again?  
Or another airplane unexpectedly pulls out in front of you while taxiing?  
A pilot can see "ugly" clouds off the end of the runway and decide that it would be better to wait a bit before taking off.  
What happens when a flock of birds suddenly appears during the takeoff roll?  
What happens when a passenger gets sick or unruly?  
When do you need to divert and when can you continue? 


On a typical flight, a pilot will make hundreds of small decisions that can make a big difference in the flight.  Any one of these (or one of the tens or hundreds of thousands of other things that could happen) could trip up a computer.

The pilot is also there as the "final authority".  If a hacker were to somehow hack into the automated systems, a pilot can always disconnect them and fly the airplane manually.  He can turn off systems, he can be...  Well, the pilot can be creative and a computer can only do what it was programmed to do.

Right now when a drone crashes it isn't such a big deal because nobody was on board.  If an airliner with a load full of paying passengers crashes it is a big deal.  Even just one.

Many of these problems can be overcome.  Some of them already have been.  Some of them may never be fully handled in an automatic way but maybe we could still do automated flights with an acceptable level of safety.  Some automation is actually better than some pilots in certain areas.

However, the biggest reason that we don't have fully automated passenger airplanes is because the general public feels comforted by a person being up front who can take over and carry them to safety if needed.  Even if the technology were 100% ready for automated passenger flights, I think that the number of people willing to purchase a ticket would be so low that it would be financially unfeasible for an airline to deploy it.