Sonny Died because it was the only way the Barzini alliance could salvage a tie. The book goes into greater detail about the War, in the book it says that Sonny's tactics were slowly winning him the war and he weakend the otherside far more than his own despite his aggressive approach. The Barzini alliance could only save what little they had by throwing one final blow and that was to kill Sonny.
The Real reason Sonny died was because
Mario Puzo wanted to further the story line and setup Michael's entrace to becoming the Don. Lets be honest we all wish everything was peaceful for the Corleones and that neither Fredo nor Sonny or the Don for that matter had died but then we would have no conflict and the Story would be boring.