What is the reason an NFL team loses a timeout if it challenges and the challenge fails?
This can be answered definitively, without much speculation, by reading articles from the NFL.
The initial replay system, in place from 1986 to 1991, was scrapped for two reasons:
After a six-season run, instant replay met its demise in 1991 when 17 owners voted against renewing the system. The belief: The system delayed games too much and failed to get enough of the calls correct.
And while it probably didn't slow the game down that much, coaches were challenging a lot, and not winning very many challenges:
1991: 224 games, 570 challenges (2.5 per game), 90 overturned calls (15.7%)
So, it took almost 15 minutes of added time (say, 2 minutes per call, and almost 1/7 overturn rate) to get one overturned call.
When replay was being re-considered, in 1996, not only did they try to do a better job of getting calls correct, but they also added the following rule:
Each coach could challenge three plays per half — at the cost of a timeout per review. The league went away from the old version of replay officials in skyboxes and gave referees the authority to review plays on the field inside a booth equipped with monitors. And referees now had only 90 seconds to make their ruling.
However, that system (trialed in the 1996 preseason) was not passed, because:
Despite the changes, owners voted against implementation for the 1997 regular season. The main hang-up centered on each review costing teams a timeout, even when a challenge was successful.
And as such, when replay was reconsidered again in 1999, it was with the following change:
Coaches, unwilling to trade a timeout for any review, would now be charged a timeout only for unsuccessful challenges.
So you can see the progression: First replay was too slow and had too many challenges, and so they added the idea of a replay using a time-out, to both reduce spurious challenges and reduce the length of the game. The coaches didn't support that, but did agree to a compromise - losing a timeout on an unsuccessful challenge.
Bottom line: because that's what rules say. Quoting from the 2015 Rulebook, Rule 15, Section 2, Article 1:
Each challenge will require the use of a team timeout. If a challenge is upheld, the timeout will be restored.
As for why that was the rule chosen by the NFL, you're into the area of speculation, but a challenge is in some ways similar to a timeout in that it gives players a chance to catch their breath, make substitutions etc. Obviously it doesn't stop the clock, but there has to be something to stop teams being able to throw a spurious challenge flag purely to slow things down.
Because it is a timeout. When you throw the flag the clock stops. The play is reviewed and then the clock is only wound when the referee sets the ball. And then the offense could run a play in less than 5 seconds.
So basically any smart coach with 2 timeouts and a minute to go would use the challenge flag as soon as he could if he weren't charged a timeout. So instead of losing 20 seconds on a play they would lose 3-5 seconds. The rule was put in for this exact fact. We would have mindless flags at the end of each game.