Why does “Wearing Green Hat” mean cheating in China? (戴绿帽子)

You would not feel anything weird If you were told that “Your lover is wearing a green hat” You might wonder what’s wrong with wearing a green hat. However, you might cry if someone told you that phrase in China because that phrase can be implied as “Your lover is cheating on you!”