(at around 18 mins) Dropping Ted on the stretcher wasn't scripted. When it happened, they cut to make sure Ben Stiller was okay and then thought it was so funny they left it in.
According to Bobby Farrelly, the scene where Ted accidentally gets his scrotum stuck in his pants fly was inspired by a real incident, when their sister was listening to some records with some eighth grade students in the basement of their house: "One of the kids went up [to the bathroom] and he zipped himself up. He was in there for a long time. My dad, who was a doctor, actually had to go in and say, 'Hey, kid. You alright?'" His parents never told them the story until years later because they wanted to save the kid embarrassment. "When they told us, we were laughing so hard, we were like 'Oh, my God.' So we just worked it into the story."
(at around 1h 27 mins) The dialogue between Mary and Ted about how there aren't enough meats on sticks was originally written for an episode of Seinfeld (1989) that never aired. The Farrelly Brothers liked it and bought it for use in the movie.
The studio was initially reluctant to allow Ben Stiller - the Farrelly Brothers' first choice - to star, so the brothers decided upon a then unknown Owen Wilson instead. When the studio was even more reluctant to let Wilson star, they agreed to allow the Farrellys to cast Stiller.