This is one of those questions that treats a fictitious character as a real living human being, and then asks about the character what can only be asked of a real human. As a construction, Cervantes chose to give the invention "Don Quixote" a history of twisted perception of his "real" world, imaging a romantic role for himself as was popular in the days of chivalry. Diagnosing him as "insane" or "sane" would depend on a whole new fictive history for him; just as an "insane" person in real life needs to deviate from his own past in some sort of way that is diagnosed as "insane" or "illogical." I have no objection to talking about Don Quixotes' eccentricities, but I do object to inserting "modern" taxonomies to the discussion.
He is mad. While it isn't always easy to classify a character in this way, he is clearly delusional. The book puts this in terms of the humors, which were the basis of the current understanding of medicine. He was previously a normal man, but after reading too many romance books and taking poor care of himself, his humors went out of balance and he became convinced that all the books were true. He is then convinced that he is a knight on an important quest. He puts everything in the world into the light of this delusion. Inn keepers are lords, prostitutes are ladies, and one local man becomes his squire. In short, he struggles with telling fiction from reality.
However, the reason people often think of him as being sane is that his overly romantic perspective on his country and the world around him inspires others to be better. He does not see the world as it is, but his optimism and passion redeem him somewhat. This is part of what makes him both lovable and tragic. We deeply wish that he were sane, but we know that he is at least partly delusional. He sees the world as people wish it could be, rather that how it actually is.