Let that be a lesson to you.

Literal

Good medicine [to-に] will-become [probably-だろう].

良い薬になる ('to become good medicine') is an idiomatic phrase meaning 'to serve as a valuable lesson, teach (someone) a lesson.' The metaphor treats a bad experience as beneficial medicine. A slightly schadenfreude-tinged phrase.