What is the significance of, and reason for, wrapping the entire content of a JavaScript source file in a function block?

I have started learning JavaScript Course, and I need some help with understanding the reason for wrapping the entire content of a source file in a function block.