Development
The production staff had considered a film adaptation of The Simpsons (1989-present) since early in the series. The show's creator, Matt Groening, felt a feature-length film would allow them to increase the show's scale and animate sequences too complex for the TV series. He intended the film to be made after the show ended, "but that [...] was undone by good ratings". There were attempts to adapt the fourth season episode "Kamp Krusty" into a film, but difficulties were encountered in expanding the episode to feature-length. For a long time, the project was held up. There was difficulty finding a story that was sufficient for a film, and the crew did not have enough time to complete such a project, as they already worked full-time on the show. Groening also expressed a wish to make Simpstasia, a parody of Fantasia (1940); it was never produced, partly because it would have been too difficult to write a feature-length screenplay. At another point, it was briefly suggested to do an anthology-style Treehouse of Horror film, but such suggestion was never pursued. Recurring guest performer Phil Hartman had wished to make a live-action film based on his character Troy McClure; several of the show's staff expressed a desire to help create it, and Josh Weinstein proposed to use the plot of the seventh season episode "A Fish Called Selma" for the film, but the project was canceled following Hartman's death in 1998. The project was officially green-lit by 20th Century Fox in 1997, and Groening and James L. Brooks were set to produce the film.
The voice cast was signed on to do the film in 2001, and work then began on the screenplay. The producers were initially worried that creating a film would have a negative effect on the series, as they did not have enough crew to focus their attention on both projects. As the series progressed, additional writers and animators were hired so that both the show and the film could be produced at the same time. Groening and Brooks invited Mike Scully and Al Jean (who continued to work as showrunner on the television series) to produce the film with them. They then signed series director David Silverman to direct the film. The "strongest possible" writing team was assembled, with many of the writers from the show's early seasons being chosen. David Mirkin, Mike Reiss, George Meyer, John Swartzwelder, and Jon Vitti were selected. Ian Maxtone-Graham and Matt Selman would also join later, with Brooks, Groening, Scully, and Jean also writing parts of the screenplay. Sam Simon did not return having left the show over creative differences in 1993. Former writer Conan O'Brien expressed interest in working with the Simpsons staff again, although he later joked that "I worry that the Simpsons-writing portion of my brain has been destroyed after 14 years of talking to Lindsay Lohan and that guy from One Tree Hill (2003-2012), so maybe it's all for the best." The same went for director Brad Bird who said he had "entertained fantasies of asking if [he] could work on the movie", but did not have enough time due to work on films like The Incredibles (2004) and Ratatouille (2007). The producers arranged a deal with Fox that would allow them to abandon production of the film at any point if they felt the screenplay was unsatisfactory.
Work continued on the screenplay from late 2003 onwards, taking place in the small bungalow where Groening first pitched The Simpsons in 1987. The writers spent six months discussing a plot, and each of them offered sketchy ideas. On their first brainstorming session, Scully suggested a story in which Steven Spielberg (intended to be voiced by Spielberg himself) would try to blow up Springfield so he could shoot a film with Tom Hanks (who ultimately made a guest appearance voicing himself in the finished film). It was also on this same reunion that Groening introduced the idea of Homer adopting a pet pig, inspired by a pig-waste management story he had read in the news. Jean suggested the family rescue manatees, which became the seventeenth season episode "The Bonfire of the Manatees", and there was also a notion similar to that of The Truman Show (1998) where the characters discovered their lives were a TV show. Groening rejected this, as he felt that the Simpsons should "never become aware of themselves as celebrities", but the idea was later used in the video game The Simpsons Game (2007). Groening read about a town that had to get rid of pig feces in their water supply, which inspired the plot of the film. The decision for Flanders to have an important role also came early on, as Jean wished to see Bart wonder what his life would be like if Flanders were his father. Hank Scorpio, a character from the eight season episode "You Only Move Twice", was originally meant to return as the main antagonist, but the staff dropped the idea and created Russ Cargill instead.
Having eventually decided on the basic outline of the plot for the film, the writers then separated it into seven sections. Jean, Scully, Reiss, Swartzwelder, Vitti, Mirkin, and Meyer wrote 25 pages each, and the group met one month later to merge the seven sections into one "very rough draft". The film's screenplay was written in the same way as the television series: the writers sitting around a table, pitching ideas, and trying to make each other laugh. The screenplay was rewritten over 100 times, and at one point, the film was a musical. However, the songs were continually being shortened and the idea was dropped. Groening described his desire to also make the film dramatically stronger than a TV episode, saying that he wanted to "give you something that you haven't seen before".