There are hoards of tutorials if you google for 'as3 loading bar' or something similar. There are several youtube video tutorials as well.
Briefly how they work, a listener in actionscript listens out for how many bytes of a file (an encapsulated .swf normally in the case of a game) has been loaded [loaderInfo.bytesLoaded], and compares it with the filesize [loaderInfo.bytesTotal] to get a percentage [Math.floor((loaded/total)*100)]. This percentage can be applied to a bar graphic or something [gfk.scaleX = loaded/total].
As for why? Well it's nice to see how far through a load you are. Rather than sitting clueless as to how long you have left to wait. Is there time for a bio break? Isn't there? Can I make a coffee? All these questions answered, by a simple loading bar :P
Simply, a loading bar checks how much is loaded, converts it to a percent, and scales the loading bar along with that percent. When it hits 100%, it is done loading.