Answer:
That the gods must be obeyed but feared and that divine favor must be sought but dreaded are the ways in which cosmic irony is a part of "Oedipus Rex" by Sophocles (495 B.C.E. - 405 B.C.E.).
Specifically, irony refers to something happening other than what is intended or to something else being in effect other than what is assumed. The irony is cosmic when it refers to the universe, which is under divine control according to the ancient Greeks. These cosmically ironic experiences occur in "Oedipus Rex" when the gods must be courted with sacrificial offerings and respectful speech regarding the significant personal and professional events in mortal lives. But in return, the gods release unenviable prophecies and solutions that must be carried out to the last detail and whose thwarting carries a high price. Either way, the gods are supposed to be there to guide and yet that guidance is cosmically irionic in always involving the suffering of beloved and hated mortals.