Iruka's parents were killed in the Nine-Tailed Demon Fox's Attack twelve years before the beginning of the series. Initially, a young Iruka was present on the battlefield, and wanted to stay in order to protect his mother. His father declared that it was the parents' duty to keep their child safe from harm. He was forcibly removed from the battlefield by an unknown shinobi while he called out for his parent to no avail.
With his family gone, Iruka had no one to give him attention. Iruka thereafter became a prankster, trying to gain attention to stave off his loneliness. He would spend his time at the monument where his parents' names were engraved, and, in his darkest moments would be cheered up by the Third Hokage. Mizuki was a childhood friend of Iruka's after the Nine-Tails Attack, and usually made him feel better. In the anime, it was noted that due to other people giving Iruka more attention than they do to Mizuki, Mizuki's kindness to Iruka revealed to be an act just to gain the Hokage's approval, all the while making Iruka miserable discreetly.
Iruka became a teacher because he wanted to pass on the Will of Fire to the next generation in this manner, inspired by the Third Hokage's wisdom. When Naruto became his student, he found it awkward to deal with the person containing the very monster responsible for his parents' death. He tried to ask the Third Hokage if he could not teach Naruto, though he was eventually disabused by the notion by Kakashi Hatake. Later, Naruto went into the woods to steal items from corpses. Iruka chased him down and protected him from Takigakurespies who were attacking Naruto, eventually backed up by Kakashi. After saving Naruto and bringing back the document attached to the artefact the latter retrieved, he reprimanded Naruto for such a reckless behaviour. This would surprise Naruto as this was the first time anyone in the village showed they actually cared for his well-being. He also thanked the Third for assigning Naruto to him. He thus resolved to be straight forward and deal with Naruto strictly in class from then on, in order to train him to become a fine shinobi. As a result, Iruka became the main reason Naruto did not become a sociopath like Gaara did.