Johns gospel is carefully written such that what, at first, appears to be simple narrative, is actually profound and transformative. This is the week of Easter, where we have opportunity to reflect on Jesus death and resurrection.
Just as Daniel's friends faced the fiery furnace for not worshipping Nebuchadnezzar, Daniel himself is flung into the lions' den for not praying to the Persian king, Darius. Again we learn that God saves his righteous people and brings judgment on those who oppose him.