You can view it as irony, but it goes much deeper than that. The purpose of that ending was to show that both sides of this racial issue are at fault. The kid who killed Danny was also clearly filled with hatred, fed to him by his racist peers. It’s also meant to show that in that African-American youth’s eyes, Danny was the very evil that Danny himself saw when he looked at the African-American youth throughout the film.
In short, it shows that the problem lies on both sides of this violent racial war. Danny and the African-American youth are young impressionable boys caught in the middle of this racial struggle, surrounded by violence and hatred.
Unfortunately, Danny’s story was destined to be a tragedy. Due to his early actions, seemingly trying to emulate his brother, he fueled and basically confirmed the racial hatred felt by the African-American youth, which tipped the scales just when Danny was about to make a turn around thanks to his own brother’s change of mind, body, and spirit.
It’s a tragic ending and meant to show the constant and never ending revolution of racial hatred in this country we call America, hence the title of the film, American History X.
Here’s the sequence of events re prison time:
Derick is a super-hardcore racist neo-Nazi leader who murders three African-American kids. He then goes to prison.
In prison, he gravitates to the white neo-Nazi clique and becomes a leder in the group. OK, this makes sense.
But then he rejects the white neo-Nazi group because they aren’t pure / rigid enough; one of their members is doing business with a Latino inmate, which Derick thinks is weak. OK, this makes sense.
Then Derick forms a friendship with Lamont — a friendly African-American kid who works with Derick the laundry room.
Somehow Lamont manages to keep the African-American inmates from murdering Derick.
Derick leaves the prison as a reformed man.