Pan Am Flight 103 was a flight from Frankfurt to Detroit with stops in London and New York.
Why after taking off in London did it fly all the way to Lockerbie instead of going directly to New York? Take a look at these pictures.
The direct route you show is actually only a straight line on your map projection. The surface of the Earth is curved and the straight line between London Heathrow and New York JFK looks like this (courtesy of greatcirclemapper.net):
That still does not quite get you over Scotland, but the actual flight path over the Atlantic typically uses a North Atlantic Track. These are routes, which are redefined twice a day to make optimal use of the prevailing enroute winds. Here is one example for such tracks: (image source)
The entry points to these routes can be quite high north, therefore resulting in an optimum route over Scotland.
Because the closest distance between two point on the Earth’s surface is a curve (we are NOT having a flat earth debate here and further posts, comments or answers on that subject will be promptly deleted).
Said curve will run out over England, Greenland, then Canada and the United States.
Airliners, because of the nature of jet routes, departure, and arrival procedures often do not fly purely direct routes to their destinations.
Route selection can also be done as a compromise between to shortest route and headwinds aloft. A more circuitous route to a destination may be a little longer in mileage than a more direct route, but might save gas if headwinds are lighter on the former course.