The way browsers work in most cases, is they process the html file first (including executing any scripts in it, in order), then create DOM elements such as your paragraph.
So when your IIFE was executed, the paragraph didn't exist yet (surely this must have printed something to your console too).
console.log is a different thing - the console object exists before the html is even loaded, which is why that worked fine.
Also, you want a lower-case d in getElementById