As the Fox comedy struggled through a rocky third season, Prince’s surprise cameo arrived with rewrites, on-set panic and just enough magic to turn one post-Super Bowl episode into an instant classic.