If the 747 can fly with two engines, why does it have four engines?
What is gained by adding another 2 engines? Flights over the ocean? Fuel savings? Safety?
Simply, more engines = more power, and power is needed for several things, the first of which is, taking off. At max takeoff weight, a multi-engine aircraft has to be able to lose one engine (after reaching the go/no-go speed) and safely continue the takeoff, which means that if you could just barely fly on 3 motors, you're going to have to have 4 to meet certification (safety) requirements. For the amazing weights that the 747 can carry, it needs some pretty powerful motors, and all 4 of them, for taking off fully loaded and meeting this requirement. (Interestingly, if the aircraft is empty and could safely continue the takeoff on 2, it is typically allowed to take off with one engine already inoperative -- to ferry to a maintenance base, for instance. But this requires no passengers/freight, and thus a very light airplane.)
At cruise altitude, more thrust means a higher cruise altitude is possible, which makes for better fuel efficiency. So while a 4-engine aircraft can certainly fly on 3 engines, and in many cases (depending on weight and outside air temperature) on 2, it can't fly as high as it could with all 4. The higher cruise altitude not only makes for more efficient flight, it also keeps you above a lot of the weather out there, and in extreme cases, a 2-engine ceiling might not clear all the terrain on your route. (Again, this depends on weight & temperature.)
Modern engines have amazing reliability, and it's now considered routine to dispatch the twin engine 777 and 767 and A330 on long overwater routes, but 50 years ago, the reliability wasn't as great, so it was considered essential to have the redundancy so that if one engine failed over the middle of the ocean, there was still a comfortable margin, and you weren't now "one motor away" from going swimming.
In addition to what Ralph mentioned, up until the mid 1980s, regulations required that aircraft operating long over-water routes or other such routes with a lack of places to divert in the case of emergency must have at least 3 engines. Specifically, this applied to any route that was more than 60 minutes from a diversionary field in areas subject to FAA regulations and 90 minutes in other places. The planes used on these routes during that era consisted of 4-engine aircraft like the De Havilland Comet, Boeing 707, Douglas DC-8, and Boeing 747 as well as 3-engine aircraft like the McDonnell Douglas DC-10 and Lockheed L-1011 TriStar. These regulations were due to engines historically not having been nearly as reliable as they are today. This was especially true of the piston engines used before the jet age, but also of early jet engines.
So, to specifically answer your question, in order to serve the long-haul trans-Atlantic and trans-Pacific routes for which the Boeing 747 was intended, it was required to have at least 3 engines. Boeing apparently decided it preferred to go with 4 and keep them all wing-mounted. This also didn't require as much thrust output per engine, making the engines easier to design, especially at that time.
However, by the 1980s, jet engines had become sufficiently reliable and powerful that a new class of regulations called ETOPS (previously "Extended-range Twin-engine Operational Performance Standards," now "ExTended OPerationS") was developed to allow twin-engine aircraft to fly overseas routes, provided they met certain standards. The first aircraft certified for such operations was the Boeing 767, which was allowed to fly trans-Atlantic operations for TWA. Its initial ETOPS certification allowed the 767 to fly up to 90 minutes away from a diversionary field and this was later increased to 120 minutes after TWA had demonstrated success with the 90-minute certification. However, the original ETOPS regulations still limited aircraft to a maximum of 120 minute ETOPS on entry into service and 180 minute ETOPS was only allowed after at least a year of successful operation with 120 minute ETOPS. As such, aircraft designed during this period for long-haul operations, especially trans-Pacific, such as the MD-11 and Airbus A340, still went with 3-engine or 4-engine designs. Unfortunately for Airbus and McDonnell-Douglas, those aircraft were released right around the time the FAA began allowing 180 minute ETOPS at release.
The newly-developed Boeing 777 was the first aircraft to qualify for 180 minute ETOPS at entry into service. Largely as a result of the efficiency it gained by having only 2 engines, the 777 trounced the A340 in sales, leading the A340 program to an early death. Shortly thereafter, Boeing acquired McDonnell Douglas and ceased production of the MD-11. With the 777 now allowed to fly, not only trans-Atlantic, but also trans-Pacific routes, the need for tri-engine or quad-engine jets to fly those routes vanished. The 777 was then followed by the A330, 787, and A350 in being able to serve those routes. Each of these programs has been very successful, however, their success has largely resulted in the imminent death of the tri-engine and quad-engine models of the past. The A340 has stopped production entirely. The 747 and A380 have had scant new orders over the last few years, leading to the possibility of both programs being cancelled. According to Wikipedia, as of the end of May, the A380 has had no new net orders so far in 2015 and the 747 has had only 3 (and none in 2014.)
You have to remember the era in which the aircraft was designed. The engines weren't as powerful so they needed four to get airborne and four to fly long haul over-water routes. There are engines now that could do the job in pairs but the 747 would need to be drastically redesigned because among other problems the wing is too low to accommodate the monster engines on planes like the 767 and 777. What Boeing should reconsider was an aborted 3-engine design like a big 727. They looked at it once back in the 60's but the engines weren't there yet. Now would be a good time to reconsider.