Due to the nature of music related copyright laws, its anyone's guess. What we do know is that copyright exceptions allow for satire (using or changing a copyrighted work to make a statement on society) which this is not, and parody (using or changing a work to make a statement about the work), which this also is not. Aside from Fair Use exceptions, there is compulsory licenses for music. Since the lyrics were not significantly changed, a compulsory license would be valid. But the soundtrack release was a longer composition which could be considered to have changed the lyrics significantly, allowing a compulsory license to be pulled. Hence, Fox would have had to license the work from the owners and/or composers.
Considering this is a major production that would want to avoid any lawsuits or complications, they likely did license it even if they wouldn't need to. Fair use and compulsory licensing is essentially decided in court. Because they rather pay a negotiated license in order to avoid the prolonged, expensive court case to maybe decide in their favor.
Note the credits state:
Based on the Spiderman Theme
Written by Bob Harris and Paul Webster
Parody lyrics written by James L. Brooks,
Matt Groening, Al Jean, Ian Maxtone-
Graham, George Meyer, David Mirkin,
Mike Reiss, Mike Scully, Matt Selman,
David Silverman, John Swartzwelder and
Attributed to the original writers.