Turns out, Jim is homesick for his family. He tells Huck a story about his daughter: he once asked her to close the door to their house, but she ignored him.
He asked her again, only to find that she still wouldn't obey him. So, obviously, then he hit her across the head, only to find out later that the child was deaf and couldn't hear him in the first place.
Sometimes we act without know the full story of things, we act by impulse and by our own thinking.