Before Hogwarts, Harry suffered severe neglect and emotional abuse as well as malnutrition and poor eyesight. The malnutrition may have physically affected his ability to learn and concentrate. Also, children who suffer severe trauma at home, as Harry did, find learning and concentrating very difficult. It is not unknown for them to learn something one day, only to forget it by the next day. In addition, Harry has never been rewarded for good work or encouraged or helped to do well. In fact, the Dursleys very strongly discouraged him from learning, studying, reading, doing homework or standing out in any positive way. These attitudes and habits developed in the first seven years of life are very hard to change and most of Harry's characteristics are not conducive to schoolwork or concentration.
On the other hand, due to his mistreatment, he has developed excellent reflexes and the ability to notice what is going on around him. While these helped him survive at the Dursleys', they also help him with Quiddich and duelling. In fact, he seems to have a very kinetic or physical style of learning, which accounts for his success in DADA. He's interested in spells that are useful, rather than theory. This is opposed to Hermione, who has a very academic or written style of learning.
Furthermore, Harry has learned a strong distrust of adults, due to his treatment by the Dursleys and presumably his teachers at primary school and other adults he comes into contact with who have failed to help him. Therefore, each year when he is confronted with danger, he does not trust the adults around him to deal with it. This only becomes worse with each successive book as the adults around him fail him in more significant ways and with worse consequences. As the dangers seem to affect him personally, he feels he must investigate and solve the problem. Most of his attention is on solving these problems rather than his schoolwork and he tends to put the minimum of effort into anything that does not seem to be related to the life-and-death situations he is pursuing. Which is, of course, very reasonable.
While some people might feel that a more sensible response would be to study hard and try to learn 'everything' about magic, that kind of decision might require more maturity than Harry possesses in the early books. The way he has been taught to NOT study and the difficulty he possesses in learning information due to his mental history and constant alertness also suggest he would not develop into a serious scholar. As shown by his research into Flamel in the first book, he can study hard, but is more likely to focus on his immediate problem rather than long term goals of knowledge. By the time he may be old enough to consider this, he is facing the possibility of imminent death (from the 3rd book onwards) and rightly considers dealing with this his priority.
Consider also the repression he has been under most of his life. He appears to have had very little time to relax, no time to play, and no one with whom to talk or be friendly. It is hardly suprising that he should want to enjoy these and prefer them to homework or studying (after all, most children do). Given the discouragement and negative feelings that the Dursleys made him associate with all kinds of work, including study, why should he be interested in doing so?
So Harry is suffering from possible physical damage to mind and body, mental and emotional trauma and has an ingrained dislike/fear of work, believing it will lead to negative consequences. He is also constantly on the alert, taking up a lot of his concentration, and his remaining concentration is focused on the danger he and his friends have discovered THIS year. To say nothing of dealing with the consequences and mental trauma of the previous years and his early life!
Quite frankly, it is astounding Harry is able to cope as well as he is.