TL;DR: The figures in the tweet are approximately correct, but it conflates gun fire deaths and homicide.
This tweet appears to be based on the recent news reports e.g., that seem to have been originally reported by WBEZ.
According to the Department of Defense and FBI data, 2,000 U.S. soldiers have been killed in Afghanistan since 2001. During that same period of time, more than 5,000 Chicagoans were killed.
Note, the tweet has subtly distorted the message. The 5,000 Chicagoans includes all homicides (clear from the context) not just gun deaths.
Now, to check those facts:
Yes, the 2,000 U.S. soldier deaths in Afghanistan estimate is about right; a slight underestimate:
The Department of Defense has identified 2,086 American service members who have died as a part of the Afghan war and related operations.
Yes, the 5,000 homicides in Chicago is about right - again, an underestimate:
Adding the figures together from the Chicago Police Statistics (Figure 1) for 2001-2011, I get 5588 homicides (which excludes 2012, but includes the first 9 months of 2001 before the October invasion).
None of these statistics include the far greater number of Aghan military and civilian deaths, so while the tweet is approximately right, the title of the question is horrendously inaccurate.