Dexter had been stalking a serial killer by the name of Arthur Mitchell, otherwise known as "The Trinity Killer", because his method was to kill three people (always in the same way), before disappearing, only to resurface later to repeat the process in an endless cycle. He had been doing it for years.
Dexter discovered who the killer was, but became intrigued when he found out that Arthur Mitchell was a successful family man and church-goer. Dexter wondered just how Arthur managed to balance serial killing with a family life. So instead of killing him immediately, Dexter decided to study him first, up-close, to see if he could learn his seemingly successful technique.
Dexter posed as "Kyle Butler", joined Mitchell's church, and wormed his way into his life as a friend. He passed up several opportunities to kill him, and even inadvertently saved his life at one time. Dexter even threw the police off Mitchell's trail, so he could personally kill him later. But it turned out that Dexter had been wasting his time. Once Dexter gained access to Mitchell's home, he discovered the truth: he wasn't a great husband and father. His family lived in terror of the maniac.
Unfortunately, by that time, Arthur Mitchell discovered that "Kyle Butler" was really Dexter Morgan, and showed up at Dexter's police station to threaten him and his family. (He assumed Dexter was planning to blackmail him.) Dexter didn't back down, of course, and Dexter eventually killed Mitchell.
But when Dexter returned home, he found that Trinity had already gotten his revenge. He had gone to Dexter's home, and had murdered Rita in the same way that he always killed the first female victim in his killing cycle: by slicing her thigh with a razor while in the bathtub.
(He didn't deliberately place young Harrison in that position. Mitchell knew nothing about Dexter's past, or about his childhood experiences, so he couldn't have been trying to recreate the scene.)
To some extent, Dexter was to blame for his wife's death. Had he simply killed Trinity when he had the chance, or had he just turned him in to the cops, Rita would be alive today. Instead, he kept him alive, for his own reasons, resulting in Rita's death. This haunted Dexter into the 5th season...