Rotation of the midgut happens during the second month of intra-uterine life. This is the gastrointestinal tract, consisting of the foregut, the hindgut, and the midgut. The midgut is continuous with the vitelline duct or yolk stalk, which later becomes obliterated.
Here's the aorta, here are the three arteries that supply the GI tract: the celiac for the foregut, the inferior mesenteric for the hindgut, and the superior mesenteric for the midgut.
As the midgut develops it protrudes into the body stalk forming a loop, with the superior mesenteric artery forming the axis of the loop.
As it protrudes, the midgut loop makes a quarter turn counter-clockwise, so its distal part is to the left and its proximal part is to the right. The distal part of the loop develops a bulge that will become the cecum, and the proximal part of the loop becomes quite convoluted.
During the time these changes are happening, the body continues to grow, and the abdominal cavity becomes large enough to allow the midgut to return.
The proximal part of the loop returns first. It passes under the distal part, and over to the left, that’s towards us in this view. The distal part of the loop returns last. It passes in front of the proximal part, and ends up over to the right.
Let's look at the same sequence of events from in front and somewhat to the left, so that we can understand how these changes produce a rotation of the midgut.
Here's the midgut loop protruding towards us, and making its first quarter turn counter clockwise. A bulge appears for the cecum, and the proximal part of the loop becomes convoluted.
The abdomen becomes larger, and the proximal limb of the loop returns. It passes under the distal limb, in effect making another quarter turn counter clockwise. Then the distal limb returns, completing the third quarter turn. This proximal part of the midgut, the distal duodenum, ends up behind this distal part of the midgut, the proximal transverse colon.
Understanding those developmental changes helps us understand not only where the duodenum lies, but also why the colon is where it is.