What follows will overlap with the great explanation Peter already provided, but, hopefully, some additional useful factoids. ; )
"STP is used at layer two to prevent loops within the network. It logically disables a link to prevent looping."
Yup. Although Peter describes STP for switched Ethernet networks, it actually comes from bridged Ethernet networks. As a switch is a multi-port bridge, why mention this? Well, it explains where the B in BPDU comes from.
"Best practise is to manually configure the device nearest the router as the root bridge. (Example topology attached of 3 switches automatically configure by STP and one image of what I think is the best practise manually configure)"
That's an it depends.
Often you do want a LAN segment's gateway router(s) close or even connected to the root bridge, as the root bridge is often the chosen to be the physical "center" of the network, i.e. least amounts of hops between it and any other bridge.
In your attachments, note how your bridge is just one hop from your other two bridges, but your two leaf bridges are two hops from each other in both cases.
However, as bridges can use different media types, perhaps the shortest path, in hops, uses 10 Mbps, while a slightly longer path, in hops, uses 100 Mbps. Should your root selection, be adjusted for that? (At least for Cisco's STP, probably not, as links costs [based on bandwidth] can be used too, I recall.)
"Spanning Tree PVST is the best option available within cisco packet tracer this is Rapid spanning tree per VLAN and expediates the wait time."
If rapid-PVSTP support, yes, generally rapid variant always a better option, regardless PT or real-world.
BTW, PVST is Cisco proprietary. Standard STP is not per VLAN.
Standard rapid-STP is much better than standard STP. Likewise Cisco's rapid-STP is much better than its PVSTP. (BTW, rapid STP variants use many proprietary options Cisco defined for its PVSTP; a couple, though, I believe still unique to Cisco's rapid-PVSTP.)