It comes from things built for children to play in that have an edge with contents inside it. You play "in a sandbox" without having to deal with anything outside of the sandbox.
The sand in a children's sandbox spills over and gets everywhere. The children playing inside it .. they don't have to care. They are playing inside the sandbox, and for now, the world outside it is not relevant.