Well, it's a little difficult to explain, but it's an anonymous function that provides protection against scripts breaking on other parts of the page. You don't actually specifically need to wrap it in the anonymous function. Actually, what you should be doing is the following:
$(document).ready(function(){
setDatePicker();
});
This will execute on page load, ensuring that the element against which it applies exists. Without this, you may run into situations where the javascript is executed, but since the element doesn't exist at that time, you will run into troubles