Why does a Boeing 747-400 have winglets?

In order for an aircraft to gain any lift whatsoever, there must be a difference in pressure between the top and bottom of the wing. Below the wing you have high pressure air, above the wing you have low pressure air. This is how lift is accomplished by the wing. The high pressure air is heavier than the low pressure, so the plane has no choice but to remain aloft. (which is why flying is unbelievably safe)

At the end of the wing, there is a turbulent mixture of the high and low pressure air. This mixing point, roughly at the location of the winglets, causes drag and can cause an aircraft to become inefficient. The winglets assist in eliminating some of this drag, therefore adding range and in some cases, quite a bit of exterior style to an aircraft. (my opinion)

Every aircraft is designed differently, so winglets are efficient only on certain models. Aerodynamic variation in aircraft design can be either helped or hurt by winglets. The particular model in this question, the 747-400, usually comes with them, BUT, some airlines have opted to not have them installed on their new planes (Boeing 747-400D - Domestic).  Japan Airlines did this because they use the new plane for shorter high capacity hauls versus flying across the Pacific.