In Game of Thrones, Olenna Tyrell waited until the Purple Wedding to
to assassinate Joffrey.
Why wait until then?
I don't think this is explicitly stated in the books or TV show, but my interpretation was this:
Lady Olenna knew from her conversations with Sansa that
Joffrey was a monster, and that she did not want Lady Margery married to such a man.
she still wanted Margery to become the Queen. The only way to achieve both goals was to kill Joffrey. However, if Joffrey died after the wedding, the Tyrells would be the first ones Cersei accused: she'd recognize that they got everything they wanted, and discarded her son once they were done with him.
So, the best solution was
kill Joffrey at the worst possible time for the Tyrells: right before the wedding. This way, Joffrey is eliminated without any fingers pointed their way, and Margery is in a position to be betrothed to the mild-mannered Tommen.
Spoilers for the book (I don't know how the TV series treats this, so I can't address that):
Olenna didn't plan the assassination by herself; it was a conspiracy of her and Littlefinger and possibly Margaery Tyrell. I don't believe that it was Olenna who chose the occasion, but Littlefinger who chose it. And he chose it because the occasion of the wedding, with its mass drunkenness and mass confusion, made it easier to blame Tyrion and spirit away Sansa. Why did Olenna go along with it? We don't know what Littlefinger said to her, but we do know he can be very persuasive.
This is speculative, but by the nature of a wedding, many people are able to get close to Joffrey. This casts suspicion on a wide number of people and allows the conspirators to have plausible deniability (at the worst) or to deflect blame to another party (such as Tyrion).
It may have been difficult to arrange another opportunity that would have allowed them to point the blame away from themselves. After all, the assassination would have done little good to Littlefinger if
Sansa was imprisoned for the assassination and beyond his reach
or for the Tyrells if
Lady Olenna was accused. This might even cause the Lannisters to have the wedding annulled and/or remove Tyrells from the small council.