Or to put it another way, bootstrap is dependant on jQuery.
The reason you need to add it before bootstrap is because your browser will load the jQuery first so bootstrap can reference it. If you put it afterwards, bootstrap would not know how to accomplish the jQuery functions as it has never heard of jQuery at this point. It will most likely return a $ is not defined type error.
If you download bootstrap it includes it although you still need to link to the local file, if your using A CDN (i.e. a link tag in codepen settings or HTML head) then you’ll need to add jQuery separately with a script tag.
Scroll spy is a Bootstrap feature. but it requires Javascript. The javascript thay have written uses jQuery. Most likely to save some compatibility headaches.