This is shown fairly explicit in the show: several members of the city guard are shown going about Kings Landing early in Season 2 (if I remember correctly), executing Robert Baratheon's illegitimate children, since they presumably have more right to the throne than Joffrey. Now in ACoK, this is much less obvious, as it is only referred to in a conversation between Tyrion and Janos, right before Tyrion dismisses Janos to the Wall. My question is this: when exactly in the timeline does the massacre of Robert's illegitimate children happen in the books? Apart from this conversation, there isn't much indication that the people of King's Landing have been distressed by this, until much later when we see their anger at Joffrey for being quite a lousy king in general. Was this massacre performed recently after Ned's execution, hence why Yoren brought Gendry with him to the Wall?
Yes, the executions took place after the death of Ned Stark(because Arya traveled with Yoren). But they happened , because Cersei was worried about the throne being taking in genereal and not because Joffrey was a bad king. She knew if the truth came out everyone was in danger.
My personal Non-canon thoughts.
I never thought that the bastards had a greater right to the throne than Joffrey. If Joffrey didn't get the throne then the throne would have been given to someone else.
I mean things might have differed as since it was a noble house, but there were many others who had stronger claims. And if the pureblood Baratheon son is the king, people are probably going to accept him and not the "bastards".And if they don't accept him its because they want to accept someone else, possibly a Barantheon brother, a Tangeryn, or maybe a Stark.
So unless anyone knew about Joffrey being a bastard this wasn't necessary.