Why did lots of characters die in Harry Potter and the Deathly Hallows?

It was the middle of a war, people die in wars.