Learning 'the hard way' means that someone had to experience difficulty before they learned their lesson. For example, if a person were to crash their car while driving drunk, they might learn 'the hard way' that it is dangerous. Sometimes people say that "they'll have to learn the hard way" if they try to give advice to them but the person doesn't listen.