He lied about the wolf coming to attack the sheep because he wanted the attention. He liked to cause a lot of commotion and what better way was there to get the whole town worried! He did it multiple times as a joke and for fun, so when the wolf actually did come and the boy cried, nobody came because nobody believed him. It goes to say that you really shouldn't lie, because nobody will ever know if you're telling the truth.