One of the traditional functions of art was to show good being rewarded and sins punished, through mythological and religious stories or examples from history. Early Christianity defined the seven virtues and the seven vices (different to the seven deadly sins), those most frequent in art being charity and justice, and lust and greed. These are often represented by allegorical figures, perhaps with a symbolic attribute, for example Justice holding a set of scales, or Greed standing by a pile of treasure.
Later centuries of painters abandoned mysterious allegories and showed good and evil in real life situations. But the bravest artists, from the Pre-Raphaelites to the Post-Impressionists, abandoned the distinction altogether, expressing sympathy and responsibility for ‘fallen women’ and the poor.