If David was to be king, Jonathan as well as Saul’s other sons pretty much had to die to clear the way to the throne. It’s possible that if Saul had followed and loved God then his descendants, perhaps including Jonathan, might have kept control of the throne.
I don’t think people dying in the OT was necessarily based on whether they were good guys or bad guys. When God willed that it was time for you to die, you would die. There’s also a verse where Jonathan asks David to be kind to his family, suggesting that Jonathan knows that he and his brothers will die and David is God’s chosen king.