Theory:

"Whatif" is a poem written by Shel Silverstein. It is taken from his collection of poetry called "A Light in the Attic" (\(1981\)).  It is a light verse with the poem is humorous, short, and the subject is very light, easy to understand, and frivolous in nature. The speaker of the poem asks (to himself) a series of questions beginning with a 'what if'.
 
The poem begins with the speaker describing something that had happened the previous night. Since the poet is a male, let us assume that the speaker also belongs to the same gender. Hence, we will be addressing the speaker as he.

So, coming back to the poem, it was nighttime, and the speaker was lying down and relaxing. Naturally, he started thinking about things in general- it could have been about something that had happened or about the future that is uncertain, or maybe both.

silhouette-3125724_1280.png
The speaker lies down thinking when the whatifs creeps in

So, while thinking, the speaker suddenly started imagining various unpleasant scenarios that may or may not happen. The speaker says how 'some Whatifs crawled inside his ear', comparing the act of having such thoughts to the movement of insects. It is possible to imagine that the speaker compares the same to a bunch of parasites as he was probably very annoyed by the 'whatifs'.
shutterstock_57952864.jpg
Some whatifs crawled into the ear like a bunch of insects

The line "Some Whatifs crawled inside my ear" could be further analysed. To imagine that something is crawling through one's ears is creepy. Unlike eyes and mouth, ears do not have lids, and hence, cannot be shut as and when we wish. So, the ear is so vulnerable that anything could crawl in without a barrier.

Moreover, according to the poem’s context, thoughts can be seen crawling through the speaker’s ears. Interestingly, ears are strategically placed so that they are closest to the brain- the source of thoughts. Hence, they become an ideal route through which something could enter one’s consciousness.
 
man-5572871_1920.jpg
 
 
Also, conventionally speaking, the word "Whatif" must be written as 'what if'. However, in the poem, one could observe that the word "Whatif" is capitalised as a proper noun, written without a space as if it is a single unit, and been used as a plural. Hence, the 'Whatif' is no longer a question, but rather an object with a life of its own.

Back to the poem, we see that a group of  Whatifs have crawled through the ears of the speaker. The speaker also provides an image of the Whatifs being active in his head. He says that he could feel the 'Whatifs' jumping and moving around his brain energetically. Moreover, the Whatifs became so uncontrollable that it partied all night long. To add to the speaker's woes, the Whatifs also kept singing their old Whatif song.
 
dancing-156041_1280.png
Whatifs pranced and partied all night long
  
The song begins with a series of 'whatifs'. Speaker worries about several situations that may or may not happen in his life. He thinks, "Whatif I’m dumb in school?". This question is important for various reasons. It gives us a hint as to who the speaker is: a kid. It also exposes one of the biggest worries of a kid, which is him turning into a stupid person or being treated as one at school.
 
cartoon-1300595_960_720.png
The speaker doesn't want to be dumb in school
 
Later, the speaker wonders about a sillier scenario: he imagines the swimming-pool to be closed and wonders what would he do in such cases. The speaker probably loves swimming and is worried that he may end up missing one of the sessions.
swimming-pool-149632_1280.png
What if the swimming-pool is closed?

The third whatif is about the situation where the speaker might get beaten up. It is a worry that many students have. The kind of beating mentioned in the poem might be a reference to the act of bullying or may mean punishment in general.
shutterstock_786294580.jpg
The speaker is worried that he will get beaten up

The poem also contains a series of other worries that are expected of a child. The speaker worries over situations such as failing a test or starting to cry. He also worries about the uncertain future when he might get sick and die.
 
sad31764111280png.png
The speaker worries about the time when he might get sick and die

The poem also contains a couple of sillier and crazier thoughts of a child. He wonders about a situation when he may end up finding poison in his cup, or worse, growing green hair on his chest.
oie_ZYBvCFNC4aWo.png
The speaker fears that he might grow green hair on his chest

The lines from "whatif I am dumb" to "my chest" contain a striking rhyme scheme AABB.
 
The whatifs continue to appear in the mind of the speaker. He wonders about a series of unfortunate events that may not even happen to him. For instance, one could see that he is worried over the possibility of  his head getting smaller. This is indeed an absurd thing to think.
 
shutterstock_159163268.jpg
The speaker is worried that his head might grow smaller
 
The speaker is  also worried over possible situations such as his parents getting divorced, unable to grow any taller, his kite being destroyed by wind, or even him not being liked by anyone. Such thoughts are common, and even natural, to kids.
 
shutterstock_533825065.jpg
Some of the worries such as kite getting destroyed by wind are common to the kids
 
Some of the whatifs are also pointless in nature as the speaker can be seen worrying over situations such as a flash of lightning hitting him, the fish not biting, and even the beginning of a war. Though pointless and silly, these worries exposes the imaginative world of the speaker.
 
pexels-johannes-plenio-1118869.jpg
The speaker fears that he might get hit by a flash of lightning
 
It is interesting to see how the whatifs are a blend of serious and silly questions and concerns.
 
Another peculiar feature of the explained part of the poem is that the rhyme scheme is not as same as the rest of the poem. The \(1\)st two lines contain the same word at the end, the next two lines have similar form of 'er' words in the end. While the \(3\)rd couplet contains rhyming lines, and the final two lines have no rhyme at all.
 
The speaker continue listing out his concerns. He is worried that his school bus would be late.  Or that his teeth would not grow straight.
 
bus-304248_1280.png
What if the bus is late?
 
He also worried about the embarrassment that he would experience if his pants get torn.
 
shutterstock_187491314.jpg
What if the speaker tears his pants?
 
The speaker is also worried about being unable to learn dance as dance is considered important for their prom night or parties.
 
dance-silhouette-5441910_1280.png
Dance is an important aspect of socialising
  
Later, when the whatif song gradually ends, the speaker seems to be glad. He says that everything seems great and happy during the day time, but when the night approaches and he is all set to sleep, the whatifs come and attack him again.