The major moral of this story is that a person must keep an open mind. Things are not necessarily as they seem and people who do not keep an open mind expose themselves to danger.
This can be seen most clearly in the interactions between Harry and his friends and the various animals (real animals or the the animal versions of animagi) in the story. The friends consistently misinterpret the intentions of the animals in the story. For example, Harry and Ron spend much of the story being angry at Crookshanks for trying to kill Scabbers all the time. As another example, Harry is terrified by the big dog. Relatedly, everyone is afraid of Sirius Black. All of these perceptions turn out to be wrong.
Because of their inaccurate perceptions, the friends get themselves in trouble at the end of the book. They also inadvertently help Voldemort by letting Scabbers/Pettigrew return to him.
The book is all about thinking you know something when you really are wrong. It is about how we endanger ourselves when we are so sure of something that we do not allow ourselves to consider that we might be wrong.