In my language, there's a saying which literally translates to
"An ignorant child learns when it itches."
It's a kind of warning that means
If people refuse to realise the magnitude of a problem when there is time to solve it, they will only realize it when they're forced to deal with the repercussions.
Consider this scene I imagined.
Family goes camping; kid touches a poisonous plant ignoring parents warning; results in itchy rash on skin.
Thus, the idiom might've originated.
I found this to have a meaning somewhat close.
To learn something by experience, especially by an unpleasant experience.
But I wonder if there's a better phrase to use when warning somebody before it's too late.