What I don't get is how no one knew it was defective.
Kisuke Uruhara knew that the container contained Kon.
According to Kon's History entry in Bleach Wikia:
Kon was one of the last Mod-Souls ever created for Project Spearhead, an operation which made Artificial Souls designed to enhance Human physiology to be placed in dead bodies in order to help the Shinigami fight Hollows. Shortly after his creation the project was deemed inhumane by Soul Society and was shut down, and all of the existing Mod-souls were to be terminated.
[Manga: Chapter 16 page 15 ]
Kon, however, made a lucky escape and wound up in the storage room of the Urahara Shop, inside a Soul Candy dispenser. Kisuke Urahara placed the tainted dispenser in a box designated as "poor merchandise" and had intended to dispose of it, but never did. [Manga: Chapter 14 page 3 ]
He knew that the contents of the soul candy dispenser is actually a mod-soul. However, He did not dispose it, maybe because of his nature, being a scientist or so, he might have thought of experimenting on it just like what he did to Ichigo to bring back his powers.
If the box wasn't marked as defective before it arrived, then Kisuke must have done it and was fully aware it was defective in the first place.
It was, actually...
When Rukia asks if her order of some Soul Candy has arrived, Kisuke tells Ururu to bring the order from storage. Searching for a box marked "new stuff", she finds a box and brings its contents to Rukia. Urahara later discovers that the box is actually labeled "poor merchandise", and contained Kon. [Manga: Chapter 13 page 10-11, 19 ]
Jinta asks her to read the writing on the box. When Ururu struggles to pronounce it, Jinta corrects her and tells Ururu that she sold a poor quality item to a customer and starts pulling her hair. Kisuke tells him to stop, saying that it is his fault for not disposing of it.source
Like Ryan said in the comment, it was on a different box. However, because Ururu struggles on reading labels, she accidentally gave the wrong item to Rukia.
Kisuke already knew what was inside: a mod- soul. He admitted it, saying it is his fault for not disposing it.
How did no one notice that Rukia's special order was defective before she came to pick it up?
They noticed that the item given to Rukia is defective after she came to pick it up. The Order was in fact okay. However, the one who handed the item had a misunderstanding. Because she struggles on reading labels, Ururu mistook the box with a label of "poor merchandise" as the box with a label of "new stuff", which Uruhara ordered her to bring, so it was the one labelled [defective] given to Rukia instead.
Jinta asks her to read the writing on the box. When Ururu struggles to pronounce it, Jinta corrects her and tells Ururu that she sold a poor quality item to a customer and starts pulling her hair. Kisuke tells him to stop, saying that it is his fault for not disposing of it. Tessai says that regardless of who is at fault, it could be trouble.
Ururu apologizes to Kisuke, saying that it was her fault and asks him if he is mad. Urahara reaches out to her, causing her to recoil. He places his hand on her head, and tells her that it is no big deal and asks why she is crying. He says that they are a team and not to worry about it, as he will take care of it. Kisuke comforts her as she continues to cry.
Tessai informs Urahara that they are ready, and the four set out to recover the merchandise, with Ururu carrying her cannon.source