"What the Hell" is a moderately fast pop punk, pop rock, and pop song, produced by Max Martin. The song is at 144 beats per minute, performed in the key of A major. Lavigne's vocal range spans from F?3 to E5. "What the Hell" opens with a "retro keyboard riff" and hand-claps. The inclusion of the keyboard has drawn comparisons to the garage rock genre and the band The Hives. The song features guitars during the chorus.
Although Lavigne simply described the song as "a broad message about personal freedom", critics have various interpretations. Gil Kaufman of MTV.com suggested that it is a "declaration of independence from a former teen star who is storming back onto the scene". Kaufman proposed Lavigne's public divorce from Sum 41 singer Deryck Whibley, along with friction between her and her record company, as possible themes. Jody Rosen of Rolling Stone magazine called the song "an anthem about a good girl... staying out late, swapping boys and exacting psychological revenge." Bill Lamb of About.com also suggested that the song was about Lavigne and Whibley's divorce but went on to say that "the song leaves significant room for interpretation which does add to its intrigue." Heather McDaid of Stereoboard.com was critical of the song's theme being about Whibley: "with such an upbeat song it’s hard to envisage divorce as the underlying subject matter as you listen." Holly Thomas of Frost Magazine suggested Lavigne was "starved of affection from the one she truly loves." Lavigne described the song as "more reminiscent of some of my old pop rock stuff", calling it her "most pop track on the record" and the least personal song from the album.