earworms are said to be largely a modern occurrence because music is engineered to be catchy (think commercial jingles) and because we are in contact with music much more often (hearing a performer sing at a pub vs pursuing play on your music player)
as to why it happens, music helps us remember things and make memories. it just so happens that commercial music production has hi jacked it to remind us that we're ba da buh buh buhhhhh lovin' it.
gonna go get some mcnuggets now...