Reverse of the medal

What is the origin of this phrase?

Reverse can mean the back of the medal.

It means a reverse of fortune, but I’m wondering how the saying came about.