Your teachers are evaluating a lot more than just your performance on homework and tests.
You can submit error-free, "A" work, but if you look bored in class, if you never ask a question or contribute to the discussion, or if you seem intent on investing as little energy as necessary to get the grade you want, you're not sending a very good message to your teacher.
I've had students ask, If I'm getting an 'A,' why does it matter how interested I look? Won't the teacher just be impressed that I can do the work so well?
It matters because the attitude you give out influences the attitude you get back. It matters because your teachers deserve some respect for standing up in front of a room full of teenagers for six hours a day. It matters because if you struggle and need help, if you need advice in the future, or if you want a letter of recommendation some day, your teacher will be more likely to extend an effort on your behalf if you've given one out. This is why some "B" students earn more glowing letters of rec than some of their "A" counterparts do.
Just doing the work isn't really giving it your all. Be interested and engaged, too. Add some value to the class for your teacher and for the other students. That's giving it your learning all.