Why do airplanes have to retract landing gear?
In the early days of aviation it was simply easier to have the gear fixed. The landing gear adds drag, but so does a second wing and wire braces. Airplanes generally did not fly very fast or far, so the drag from the landing gear (and that other stuff) was not a big issue. The first design with retractable gear dates to 1911. Since then, retractable gear has been a design decision each airplane must make.

Retracting the gear into the airplane allows for a cleaner form, which reduces drag. However, this is at the expense of added weight. The retract system, which is usually hydraulic, must be added, and the plane must be designed to make room for the gear somewhere at least mostly inside the aircraft. The plane must also be designed to handle situations where some or all of the gear does not extend properly. For planes that need to be fast and/or efficient, retractable gear is worth the reduction in drag.

The additional drag has to be supported by the structure as well. Aircraft with retractable gear will have a maximum speed at which the gear can be extended. Even gear with proper fairings would add significant drag at the speeds airliners fly at. This would be much more critical at supersonic speeds. In these cases the weight of reinforcing the gear could be even higher than the weight of the retracting system.

Particularly smaller general aviation planes tend to not have retractable gear. The retract system adds extra weight and complexity (and therefore cost), which will be fairly significant in a small plane. Fixed gear is simple and can be designed to minimize drag as much as possible. These planes do not typically need to fly fast or have large range, so the added drag is less of an issue. Other small planes do have retractable gear, which will allow for greater speed and range. The PA-32 type shown in Dave's answer was later produced in a retractable gear version as well.