Origin of ‘for shame’

Probably from forshame:

From Middle English forshamen, from Old English forscamian (“to make ashamed, be ashamed, be modest”); equivalent to for- +‎ shame.

(Wiktionary)

the expression "for shame" dates back to the 14th century as suggested by Dictionary.com