From the Super Mario Wiki
When Mario and Luigi first visit the castle, the frames on the wall are empty. As levels are scanned through an e-Reader, those containing an e-Coin will have its frame indented and its level number in the white space below. As such, the castle appears to be a sort of "museum" or trophy gallery.
The castle has three floors of eight frames each, with the second and third floors (2F and 3F) opening to Mario and Luigi once the player scans a level containing a ninth and seventeenth e-Coin. The player can teleport between floors by pressing and . However, despite the game containing the code and sprites to allow this, the e-Reader's failure saw only the completion of 1F (Super Leaf, Starman, Toad, Mario, Princess Peach, Luigi, Mushroom, Fire Flower), with American players only able to collect three e-Coins (Super Leaf, Starman, Mushroom).
It is unknown if there was to be any reward for filling all of the castle's 24 frames.