Why did John McNab take in Maniac Magee?
John McNab takes in Maniac Magee out of gratitude for making John look admirable to his little brothers.
More generally, John takes Maniac in because Maniac had looked out for John's little brothers, Piper and Russell, getting them fed and taking them back home when they had been intent on running away to Mexico.
But the more immediate reason that Maniac was invited to John's house is an interesting story. Remember that Maniac and John have met before: that Maniac, with his excellent baseball skills, had made John look foolish in front of the other neighborhood kids. Now check out that conversation near the beginning of Chapter 35, when Maniac is returning Piper and Russell to John.
Right then, Maniac invents a tale about himself and John in order to make the big brother seem to the little ones like a very dignified, very skillful baseball player. Maniac gives the young ones an entirely made-up account of John's magical "stopball" move that made Maniac look foolish on the baseball field. When he's done with this story, Russell and Piper look up at John with adoring eyes and say "Wow."
It's only then that Maniac is invited to the McNab home.