Good question!
This is so the JavaScript fires off before the rest of the page loads. This way, you know that a page was requested even if something stops the rest of the page from loading. If you had the tracking code in a footer, for example, and the footer never loads, you'd miss the hit that would otherwise come from that page. It also makes sure that the tracking code doesn't interfere with anything else that's trying to load.
Hope this helps!
Best,
Analytics Academy Staff