Why the diffraction grating works better outside at night
A grating works better at night because there is a dark background against which to view the spectrum. Inside, with other lights on in the room,  you get confused by the other things to look at. Compare the clarity of the spectra in these two pictures:
Room lights on!
Room lights off!

The other factor that makes spectrum viewing better outside is that the lights are all far away, and thus look small and often well separated. To understand the importance of this, first consider what happens when we have two light sources close together with overlapping spectra:
Where they overlap, the different parts or the two spectra combine, and our eye decides it is a different color.

A wide source (like a panel of fluorescent ceiling lights) is like many small sources bunched together. Each little part is trying to make a spectrum, but all the spectra overlap, mixing the different kinds of light back together. This makes the middle of the wide spectrum appear as white again.  As an example, here is what you see looking at a page of white paper: .
Is there a way to look at broad lights from a close distance and still be able to see a clear spectrum?   That's the next activity.