Daniel, like Ezekiel, was taken as a captive to Babylon during one of the defeats of Judah. Daniel is probably a teenager. He has witnessed firsthand the destruction of his homeland and now serves his oppressors. Daniel and his friends show a great deal of wisdom and courage by refusing to eat what was provided to them.
The food the king provided had to look and smell pretty good. The possible outcome of not eating the food would have been scary. Is our faith in God this strong?