Spoilers from here for The Dark Knight and its sequel.
Because Dent, after becoming Two-Face, killed five people and threatened a child, and the truth would have destroyed everything his prosecutions achieved. Batman takes responsibility so that Dent can be buried as a hero.
What Dent actually does
After Rachel's death and his own disfigurement, Dent hunts the people he holds responsible, deciding each case on a coin toss.
- Detective Wuertz, one of the corrupt officers, killed in a bar.
- Maroni’s driver, killed in a crash Dent causes.
- Maroni himself, killed in the same crash.
- Detective Ramirez, spared on the coin.
- Gordon’s family, taken hostage, with Dent holding a gun on Gordon's son.
Batman intervenes, Dent falls from the building and dies.
Why it matters so much
Because of what Dent was before. He had prosecuted most of the city's organised crime in a single operation, and hundreds of convictions rested on his credibility.
If the city learned that its district attorney had murdered people and threatened a child, those convictions become vulnerable and the moral case behind them collapses. Every criminal Dent put away gains an argument.
What the Joker was actually trying to prove
His stated objective is not chaos for its own sake. He argues that civility is a performance that collapses under pressure, and that anyone can be reduced to his level.
Dent is the demonstration. The Joker says explicitly that corrupting the city's white knight was the plan, and that everything else was a distraction. On that measure he succeeded, and he says so while hanging from a building.
The lie is what denies him the public victory. Dent falls, and nobody outside that rooftop ever learns it.
Why Batman rather than nobody
Because the deaths need an explanation. Five bodies and a hostage incident cannot be left unattributed, and a mystery would invite investigation that would eventually reach the truth.
Batman is available as a culprit, is already outside the law, and can absorb it without any of it unravelling. He is also, as Gordon's closing narration puts it, able to take it because he is not a hero in the way Dent needed to be.
What it costs
Batman becomes a fugitive and withdraws for years. The city gets legislation named after Dent, which is used to hold organised crime figures without parole, and it works.
The sequel establishes that the peace is built on the lie and that Gordon has been carrying it. When the truth is eventually released publicly, the effect is exactly what the two men feared, and the legitimacy of the intervening years is undermined.
Is it the right decision?
The films decline to say, which is why the ending works. The lie produces eight years of falling crime and a great deal of good, and it is founded on a deception that treats the public as unable to handle what happened.
Gordon is visibly uncomfortable with it from the moment it is proposed, and the sequel gives him a confession he never manages to deliver. The trilogy's position is that it was defensible, that it was corrosive, and that both are true at once.
Gordon’s position
He is the only other person who knows, and he carries it publicly. His eulogy for Dent is delivered knowing exactly what Dent did, and the sequel establishes that he wrote a confession he could never bring himself to deliver.
The decision costs him more than it costs Batman, who withdraws entirely. Gordon spends eight years being publicly honoured for a peace he knows is built on a lie.
What the film is arguing
That a city needs a figure it can believe in, and that Batman is structurally unable to be one. Dent could be photographed, quoted and elected, and Batman cannot.
The trilogy's eventual answer is that a symbol anyone could wear is worth more than a hero anyone could name, which is what the closing sequence of the third film sets up.