An ancient mystery revealed.
Wikipedia on Lockstitching:
The machine lowers the threaded needle through the cloth into the bobbin area, where a rotating hook (or other hooking mechanism) catches the upper thread at the point just after it goes through the needle. The hook mechanism carries the upper thread entirely around the bobbin case, so that it has made one wrap of the bobbin thread. Then the take-up arm pulls the excess upper thread (from the bobbin area) back to the top, forming the lockstitch. Then the feed dogs pull the material along one stitch length, and the cycle repeats.
(Image: Lockstitch, Nikolay S, CC-BY-SA)