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.)
As stated before, back in the days- the aircraft characteristics and the thrust certification of the engines demanded the aircraft design to include 4 engines in order to conform with the different regulations of ETOPS and various engine loss scenarios that can be encountered during any phase of flight.
Looking at the statistics we can see that during the last 30! years, around 15 passenger aircraft (meaning- airlines) were forced to make a gliding landing due to various reasons. Of these aircraft, none was due to a Dual engine failure that was caused by a technical malfunction. Most were because of fuel exhaustion, some due to pilot error (shutting down the incorrect engine after a malfunction) and 2 (recently) due to bird strikes. This leads to a conclusion that a 4 engine aircraft would not be immune to the dangers which led to the forced landings of the noted above, maybe except for the bird strikes- but it is very hard to make a statistical assessment of the risk due to various components of the encountered flocks, sizes and patterns of the birds.
The engines today are super reliable (as of 2019 there are some problems with the engines of the 787's but they are addressed as we speak) and one can deduce that having more engines actually brings more chance for fault, thus nowadays it is safe to say that the main consideration for aircraft design and number of engines is the final weight of the aircraft and the amount of thrust needed in order to meet all the specified gradients of climb and of course reaching a relevant airspeed in order to take off on most runways of the world which are limited by length or obstacles.
By the way- while losing 1 engine in a dual-engine aircraft can be challenging, but losing an outer engine on a 747 during takeoff results in a huge yaw asymmetry, making it even more challenging due to the distance from the center of the aircraft.
So, theoretically speaking- there is no reason for the B747 to have 4 engines. They would have to be bigger than the GE9X in order to carry it, thus leading to a re-design of the aircraft which practically has no justification. If the airlines found that it can be more profitable to run all planes on 4 engines (including risk assessment, investment and wear cost)- we would have been seeing more and more of those flying.
The 747 began life in the mid 1960s, as an alternative to the Boeing 2707 SST. To hedge their bets, the 747 was designed to be converted to a freighter as well. Hence the bulge at the front and the top mounted cockpit - to facilitate a front opening cargo door. When the 2707 was canceled due to cost overruns and rising fuel prices, Boeing fortunately had the 747 well under way.
At that time, gas turbine engines were limited in power output. The 747 was the first large scale commercial application of high bypass turbofans, a fairly new technology. To meet the power needs of an aircraft with the 747's weight and carrying capacity, four engines were required. They were also required for long over ocean flights, to insure that the aircraft could make landfall in the event of a loss of an engine... gas turbines in the 60s weren't as reliable as they are today.
Once the design is set, altering it later to change to two of the new very large gas turbines that came out in the 90s would have been prohibitively expensive. Simpler to design a new large airliner with two engines in mind: the 777.
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.