So, the end of Rogue One just had to end the way it did and without it, the movie would not have been so highly regarded by fans.
If the writers didn’t kill off the cast of Rogue One, fans would have certainly wondered why they were never mentioned in the Star Wars franchise starting with A New Hope.
In the movie, they are able to send out the weakness of the Death Star to the Rebellion right before their demise, allowing for Luke Skywalker’s heroic journey to still make sense and feel untouched.