The most direct route between two points is known as the "Great Circle" line that connects the two points.
Flights will often deviate from the Great Circle routing for a variety of reasons. First, is air traffic congestion; air traffic control can route planes through different corridors if others have too many planes already in them.
Second, is wind/weather. For example, the Great Circle route from SFO to Asia is to first head north up to Alaska and then back down south along the Aleutian Islands. However, if the headwinds are too strong then it often becomes faster to fly a more southerly route that is longer distance wise. In the case of a massive storm along the Great Circle path, the plane will also deviate from the shortest route.
Third, a plane will not fly the Great Circle route if there are no suitable diversion airports along the flight path. This a bigger problem for two-engine long haul planes like the Boeing 777 and the Airbus A330 as they must adhere to the Extended-range Twin-engine Operational Performance Standards (ETOPS).
Essentially, if one engine goes out, a plane's ETOPS rating says how long that plane can fly on a single engine.
Lastly, routings can be impacted by no-fly zones that may lie along the path. For example, El Al, the Israeli airline, does not fly over much of the Middle East for security reasons. On their flight from Mumbai to Tel Aviv, they are forced to fly around the Arabian Peninsula, significantly increasing flight times.
On July, 8th two Airbus A380 took off from London Heathrow at about same time, to same destination. Thanks to Radarbox, we followed that race to Singapore.
Qantas #QF2 to Singapore was late and took off at 21h32 UTC and chose a North route.
Singapore Airlines #SQ321 took off only 2 mins later at 21h43 UTC but chose a South route.
The both routes joined over Turkmenistan and the two A380 followed each other with a slight advantage to Singapore Airlines despite it was the second to take off.
But ATC gave a real advantage to the Singapore Airlines flight which did a direct approach to Singapore Changi Airport from North.
Singapore Airlines flight #SQ321 landed on July 9th at 10h05 UTC and Qantas #QF2 landed 18 mins later.
In this case, the pilots chose a slightly different route for the beginning of the flight but finally joined in the middle of the journey and reached Singapore airspace at the same time.