The script was written by Apatow when he was still a struggling writer, according to Entertainment Weekly.
After hearing about the existence of the script, The Simpsons exec producer Al Jean invited Apatow to submit his episode to the show's production team.
"We're always looking for good shows and good writers," said Jean. "I sent word to him - 'If you're interested, we'll buy it.' I think he had to find it - it was in one of his boxes."
Apatow is known for directing such films as 2005's The 40 Year Old Virgin, 2009's Funny People and the forthcoming This Is 40.
He has also contributed to the screenplays for 2007's Walk Hard: The Dewey Cox Storyy, 2008's You Don't Mess with the Zohan and the same year's Pineapple Express.
His past television work includes NBC's Freaks and Geeks, Fox's Undeclared and HBO's Girls.
> Channel 4 admits cutting word 'gay' out of The Simpsons
> The Simpsons Mr Burns supports Mitt Romney - video
Watch a trailer for Judd Apatow's This Is 40 below: