See the example of the candlesticks [from Les Mis][1].

See also Gen 20:60 

> ...you meant it for evil, but God meant it for good.

Can someone tell me the name and origin of this theological concept?  

Specifically, what is the name and origin of the idea that God justifies a sinful act by restructuring the narrative surrounding it?

  [1]: https://youtu.be/yhpwV4cwB4o?t=1m46s