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?
1Gendry was being hunted under orders from Cersei. It stands to reason that the other bastards were being hunted at the same time. I don't have the passages to hand, however.– NickAug 7, 2014 at 15:10
In the A Song of Ice and Fire novels, the massacre of Robert Baratheon's bastards is ordered by Queen Regent Cersei Lannister (not Joffrey) shortly before the arrival of Tyrion Lannister the capital. This was not the first time Cersei ordered the death of a bastard child of her husband; according to Littlefinger, a pair of twins Robert fathered on a servant at Casterly Rock had previously been murdered (it is unknown if the story is true).
Barra is the only one reported to die in the books, while in the show at least four others of Robert's bastards were killed too.
Gendry is spared from the massacre because Varys had foreseen this would take place and arranged his escape from the city in Yoren's caravan.
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.
Bastards are not allowed to inherit their father's lands or titles, and have no claims to the privileges of their father's House. It is up to their father on how to raise or treat them: at worst they are unacknowledged and ignored, though they may fare better and be discreetly sent funds to ensure their well-being. At best, a lord will acknowledge his bastard children (allowing them to take on one of the special bastard surnames), but send them away to one of his distant castles to be raised away from his lawful family.
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.
Nevertheless, as a highborn bastard carries the blood of a noble house, they may still be perceived as a potential threat by rival claimants. For this reason, King Joffrey orders the massacre of all of his father's illegitimate offspring
So unless anyone knew about Joffrey being a bastard this wasn't necessary.
1Bastards can also be "raised", or given legitimancy. I think it's normally done by the head of the House, but there may be some other way for a bastard to be officially recognized as a legitimate heir of the House.– Joe L.Aug 7, 2014 at 16:01
2@JoeL.- That is true. But usually in those situations, the bastard has been recognized by his father. In this case, even if Stannis and Renly had been passed over for whatever reason, the throne probably would have gone to Edric Storm. More importantly, bastards can only be legitimized by a king, at which point the purpose for legitimizing Robert's bastards to begin with is a moot point. Aug 7, 2014 at 16:27
10The fact that two successive Hands based their determination of Joffrey's incestuous illegitimacy upon the inherited traits of the set of known bastards provided more than enough reason to kill them. It's not that they were more legitimate than Joffrey, it's that they provided evidence that he was not legitimate. Aug 7, 2014 at 16:37
3@TenthJustice - You're missing something. If Cersei's incest is made public, all of Robert's "legitimate" children are ineligible for the throne. Under these circumstances, bastards (who at least are blood descendants of Robert) would be able to find backers, and backers mean threats. Dynastic struggles have often provided claimants with weak (sometimes laughably weak) claims, and bastard sons would probably have a decent chance in the absence of any legitimate heirs. And, of course, if they succeed their claim is obviously valid (or so the chronicles would report). History and winners, eh? Aug 7, 2014 at 22:57
@WhatRoughBeast But who will believe that. The Lannister's are strong. And it was a just a suggestion, my take on it. I may be wrong though. Aug 8, 2014 at 2:03