Daniel 1:3-5 explains how some of the young men from Judah’s royal family and the nobility were taken captive and were to be trained for three years then they would enter into the service of King Nebuchadnezzar. They were assigned a daily amount of food and wine from the king’s table. The reason why Daniel refused to eat this food and drink this wine is given in the NIV Study Bible notes:
“Israelites considered food from Nebuchadnezzar’s table to be contaminated because the first portion of it was offered to idols. Likewise a portion of the wine was was poured out on a pagan alter. Ceremonially unclean animals were used and were neither slaughtered nor prepared according to the regulations of the law.”
By providing food and drink from his own kitchens, King Nebuchadnezzar was trying to create a bond of dependence, gratitude and loyalty from the captives, but Daniel and his compatriots were having none of it. The NLT Study Bible comments that Daniel and his friends were not going to yield their religious and moral independence to the king.
The fact that they appeared more healthy after the ten days was a beneficial result, but was not the reason for abstaining from the food and drink prepared in King Nebuchadnezzar's kitchens. Their absitnance was based on remaining true to God's instructions.
EDIT: After the flood God told Noah that everything that lives and moves could be eaten as food - this in addition to green plants (Genesis 9:2-4). So Daniel and his companions were at liberty to eat meat. What they couldn’t eat, however, was meat that had not had the lifeblood drained out of it or meat that had been sacrificed to idols. In pagan Babylon, ceremonially unclean animals were eaten and were neither slaughtered nor prepared according to the regulations of the Mosaic Law. That is why Daniel and his companions refused to eat the food from Nebuchadnezzar’s table – they were not prepared to break the Mosaic dietary laws. This was an issue of obedience to God’s laws.
Daniel said to the guard who had been appointed over himself and his three companions ‘Please test your servants for ten days: Give us nothing but vegetables to eat and water to drink. Then compare our appearance with that of the young men who eat the royal food, and treat your servants in accordance with what you see.’ So he agreed to this and tested them for ten days” (Daniel 1:8-14). Clearly, this rather stringent diet did not harm them physically or mentally, but to claim that it was the diet that was responsible for wisdom and understanding dreams is to deny the power and will of God in the events that unfolded.
Take the example of Joseph, who was sold into slavery and imprisoned because he refused to sleep with his master’s wife. In Genesis 40, Joseph correctly interpreted the dreams of two of Pharaoh’s servants. Later, Joseph interpreted the king’s dreams. Was the ability to interpret dreams as a direct result of Joseph being on a prison diet of bread and water? Was it Joseph who took the credit for dream interpretation? Of course not! It was God who gave Joseph (and Daniel) the interpretations.