Where It All Goes Down
Babylon and Susa
Ah, Babylon—the Biblical city standing for all things corrupt. But you know what? The Book of Daniel doesn't make it look that bad—we mean, aside from all the getting thrown into furnaces and lions dens. It's supposed to be better than the empires that follow it, anyway. The Babylonian kingdom takes the gold, whereas the Medes, Persians, and Greeks need to content themselves with silver, bronze, and iron respectively.
Babies in Babylon
Why Babylon? Well, Daniel, along with a whole bunch of people who in no way wanted to go, ended up in Babylon because, in 586 BCE, the Babylonian empire sacked Jerusalem, razed Solomon's Temple to the ground, and yoinked a ton of Israelites into exile. This was a very unpopular decision (see the Book of Jeremiah or Lamentations to hear some real weeping about it), but Daniel seems to do pretty okay for himself.
And that makes Daniel all the more heroic. To an ancient Jewish audience, the whole book would've read like a hero (Daniel) in a metaphorical lion's den (Babylon), surrounded by hostile and murderous forces that wanted to deny him of his faith and culture. When he wins (as he does a whole lot), it's a come-from-behind victory. Daniel doesn't just get his comeuppance against a tribe of randos—he gets his comeuppance against the empire that robbed Israel of its political autonomy and religious structures.
Ah, sweet revenge.
Princes in Persia
But all of the action isn't confined to Babylon. Daniel has one of his visions in the Persian capital, Susa, as well. This is because, in 539 BCE, the Persian empire trounced the Babylonian Empire, and sent many of the Israelites back to their homeland, with a "we're sorry" and permission to rebuild their Temple. Not everyone got to take the return trip (Daniel's seems delayed, for instance), and Israel was still, of course, under foreign subjugation. Nobody likes to be subjugated. But Daniel, of course, wins the day once again, demonstrating his capacity for victory under not one, but two empires. You cunning dude.
Gripes with the Greeks
These settings—living under foreign kings in a hostile land during roughly 600-500 BCE—are very similar to the setting in which the book was actually written.
The Book of Daniel, though its likely derived from some oral traditions and legends that had been floating around for a long time, was put together in its final form sometime around 165 BCE, when the Israelites were squabbling with the evil Antiochus IV Epiphanes, a leftover Greek general jockeying for influence in the post-Alexander-the-Great era. Antiochus IV Epiphanes wasn't the kindest to the Jews (understatement), and tried to prevent them from worshipping and practicing their religion freely.
The Jews put together a rebellion (that sort of worked, surprisingly enough), but when Daniel was written, they were still getting their gripes over the unfairness of foreign kings out in the open.
Given this compositional setting, it makes sense that our author highlights the travails of some cunning heroes also living under hostile foreign kings, in Babylon and Persia. The past setting helps shed some light on the present situation.