While this act of gratitude and kindness on the part of an escaped convict may seem be surprising and incongruous to the reader, Charles Dickens in this early chapter of "Great Expectations" sets the stage for his Appearance vs. Reality theme.
Disgruntled with the social system in his country that judged people by their class, Dickens contrasts the poor, but kind and decent underprivileged Magwitch, who was forced to steal in order to survive, with the corrupt Compeyson, the "second convict," who has exploited Magwitch for his personal gain. For, as the plot develops, the reader realizes that the appearance of class and wealth does not equate with goodness and integrity.
The reason that the convict does this is because he does not want to get Pip in trouble. This is pretty nice of him considering that he had threatened that his (unseen) partner would kill Pip if Pip didn't bring him food.
Because he had been threatened, Pip stole the food from Mrs. Joe's kitchen and brings it out to convict. Later on, the soldiers come through town and Pip and Joe go with them thinking it will be fun to watch them search for the convict. Pip is afraid the convict will think he told the soldiers where to look, but the convict does not think so and is nice enough to not get Pip in trouble.