This is highly philosophical question. Of course, religion has a function. It is there to educate people. Priests are like teachers. They show us how to educate our spirit. Priests are human like us. They are not perfect. For that reason, they make mistakes just like us. Religions, no matter what we say, have been invented by men. In that case, they cannot be perfect. Nothing on Earth is perfect. Even the atheist cannot find perfection in their denial of God. I believe that religion works like a school. It is just there to teach. Now maybe the methodology is not good but the purpose is respectful.