Robert Baratheon won the Iron Throne by conquest, so while he did start out as a usurper, he was the rightful king.
The realm just ran out of Baratheons.
Cersei’s claim to the throne comes from her status as Robert’s widow, and therefore the closest thing the Baratheon-free kingdom had to a rightful ruler.
Even though the Lannisters did kinda sorta arrange for him to die, and even though Joffrey, Tommen, and Myrcella were actually pure Lannister, the Baratheons never lost the throne.