"his rabbit" is the indirect object of "gives". Ming Hua gives to his rabbit.
Put them together and you get:
"Ming Hua gives his rabbit a carrot.
"to eat" is a to-infinitive which is added on to explain the purpose of Ming Hua giving his rabbit a carrot:
"Ming Hua gives his rabbit a carrot to eat."
That's all basic, and the sentence is correct.
However, the teacher's sentence "Ming Hua gives his rabbit to eat a carrot." has only one object (indirect) and a to-clause. This is OK for verbs such as allow, permit, which do not take a direct object. eg.
"Ming Hua allows his rabbit to eat a carrot."
"Ming Hua permits his rabbit to eat a carrot."
But "give" requires two objects, a direct, and an indirect one.