While the Bible talks at length about religious ceremonies conducted in the Temple at Jerusalem, I’ve seen very little information about living quarters and what one did there when they were not actively performing religious duties. I’ve wondered this especially in the case of Samuel, as he moved to the Temple at a very young age - so, for example, was there some kind of program set up for children there?
There were not many priests who lived near the temple. The majority of priests took turns serving in the temple. They were divided into 24 groups. Each group served in the temple twice a year for a week, roughly six months apart. That covered 48 weeks. The remaining 4 or so weeks of the year were covered by the three major feasts: Passover (Spring), Pentecost (Summer), and Trumpets (Autumn). During the three major feasts, all of Israel came to the temple and all the priests served in those weeks because of the much greater attendance at the temple.
So the short answer is, most priests did not live at the temple. They lived in the Levitical cities around Israel and only traveled to live briefly in Jerusalem for their week of service.
According to Ezekiel 45-48, the priests had quarters in the rooms surrounding the courts of the temple. These likely served as their temporary accommodations when they took their turn serving a the temple. According to the gospels, the high priests' family, which were continually at the temple, had a separate residence in Jerusalem.
Some interesting resources on this topic:
In the case of Samuel, it is clear he was given over to Eli the High Priest as his guardian and seems to have been living in Eli's private home.