I don’t think the plan is that far-fetched necessarily; after all, it worked in the real world with Anne Boleyn (and Jane Seymour) even without the added sting of adultery in the former.
Certainly, there was a danger that Robert would set her aside as he did Delena Florent, but I think there were some factors working to mitigate that:
- Margaery was not merely highborn but a lady of a Great House, and royals dishonoring Great Houses can lead to outright rebellions so setting her aside has more downside risk than with Delena. Robert might be fickle but he’s also conflict-averse.
- When Robert set Delena aside, he already had a male heir with Cersei. There was no need to legitimize a bastard through marriage to the mother in order to procure legitimate offspring. If Joffrey et al. are disinherited, all of the sudden Robert really needs a male heir in a hurry.
- The correct timing of the reveal would make Robert more likely to cleave to Margaery than set her aside: having his queen commit adultery with her brother is not only an act of treason but a huge loss of face for Robert as a virile macho king figure; here’s Margaery to consolingly tell him that he’s definitely all man in the sack (she can’t get enough, really), that the evil queen only did what she did because Lannisters are all evil and crazy, and Margaery’s love is true and pure and the proof of it is that she’s pregnant (which proves how virile he is) and of course as noble a king as Robert would never dishonor her instead of marrying her, and of course when he does daddy will step up and pay the bills just like the mean old Tywin used to do, and brave ser Loras who’s been like a son to him will help you crush the treasonous Lannisters like the manly man warrior he still is.