He asked to borrow a big pencil from Topanga, and Shawn, attempting not to get between Cory and Topanga during their breakup, immediately snapped at him. The outburst led to them all getting detention.
In detention, Cory said Kenny was lucky just to be there, but Kenny disagreed. Ironically, Kenny was killed by a big pencil through the forehead. Just before that, he had said that "nothing scares him" and that "Topanga doesn't belong to Cory."
After he dies, Eric exclaims, "Oh my God, they killed Kenny!" This is a reference to South Park which debuted a year before this episode aired