Felix culpa is a Latin phrase that comes from the words felix, meaning "happy," "lucky," or "blessed" and culpa, meaning "fault". In its wider general sense, it describes how apparently evil or bad events [causing pain and hurt], may in the longer term produce a better outcome than if nothing had happened at all.
The Hindu Trimurti embodies the concept in the recognition that one cannot have creation unless it is preceded by destruction. That the old order has to be swept away before any new order can be established. Of course those in the old order would classify the events as bad or even evil, but there is the implied truth that any form of change is going to create pain of some sort.
The medieval theologian Thomas Aquinas recognised this when he explained that "God allows evils to happen in order to bring a greater good therefrom". But there is actually the additional and more important adjunct to this, that 'God', doesn't just allow so called evils to happen, God plans them.
They are part of the Great Work. And thus we also have the hymn ‘God works in mysterious ways his wonders to perform’.
It is only those to whom apparently bad things happen, who view the events as evil. In the overall scheme of things, the effects may be just as God wanted.
Of course, it is instructive that every so often even those actions which may seem at first to be "negative" turn out to be seen as positive, as celebrated by the concept of the felix culpa in Christian theology.
An example of this in the Merlin stories is when Merlin deceives Igraine into thinking that Uther Pendragon is her husband. The product of their illicit sex is, of course, Arthur. Merlin, like all magicians, is a deceiver. …. As von Franz puts it, "... those primal opposites which the Christian teaching has torn apart into an unresolvable conflict exist together in his nature."
John Milton includes the concept in Paradise Lost. In book 12, Adam exclaims:
O goodness infinite, Goodness immense!
That all this good of evil shall produce,
And evil turn to good; more wonderful
Than that which creation first brought forth
Light out of Darkness! [...]