2018 Update: Keys are worth 34.44-34.55 refined metal as of now, so gaining profits from crates is very difficult. On top of that, way too many hats are worth less than 3 refined, so most random hat crafting will not be worth it. the same can be said for crafting two craft hats together, as those same hats are worth less than the 2.66 refined metal required to buy the craft hats.
In conclusion, and a guess for the future: It is not worth it to try and use RNG to make profits. There is too much that can go wrong. And, it will likely stay like this until the end of time. There are some windows where the risks can yield much better profits, such as if a set of craftable items come out or if a new series of crate or cases comes out (but this window is small (AND if the window ever opens again)).
Very Out-Dated Information Below
The only reason you would want to un-crate for profit is for unusuals, salvaged crates, and the special holiday crates. All ususuals are worth more than a key, so are most (probably all) salvaged crate stranges. The holiday crate items don't start with a high price, but they usualy skyrocket after a few months. Look at festives. If you want specific items from crates, it is better to sell the keys for metal, or trade the keys directly for the items you want.
It all depends on what you are looking for. If you want profit, uncrating is not the way to go. If you want to excperience the thrill of luck, then uncrating is right for you. But, most of the time, profit is not gained from uncrating (unless Gaben is on your side).
Random crafting though, can be much more profitable than uncrating. If you buy two 1 ref hats, and craft them and get a Double Cross Comm (super rare hat), you can resell for a massive profit. But, there are low chances to get these "rare" hats, so it is not too easy to make profit. BUT, if you time it right as a new hat comes out, you can craft for an attempt at a craft # item. The values of these are very odd, ranging from 1-3 keys to 1-3 Buds, depending on the number and the hat.
The same as above applies to random weapon crafts, but random weapon crafts is much more profitable, becuase there are less total weapons. You just get a Class Token (for a class that has a rare weapon), a Slot Token (matching the same slot as the rare weapon), and a scrap, and craft them together. Some rare weapons are worth 1.33-2 ref, depending on the weapon and how new it is. The craft # bit also applies here.
Edits based on recent economy shifts:
Unless you only count the first #30 Slavaged Crate, it is not worth it to unbox Slavaged Crates most of the time. The values of the (salvaged) crates exceed the value of most of the items in it (excluding the rarest drops out of them). You can make profit from unboxing though, if you unbox at the right time. If you happen to have some tradable keys when a new crate type comes out, find a tradable crate, then unbox it, you could make profit. But, with the "wait a week to trade items recently purchased thing," this method takes lots of patience and time. Also, you would have to find someone who wants to buy the item for lots of money early, and does not want to wait. Once 1-2 weeks have pasted, the values of the items from the new crate(s) will have decreased.
The profit from Festives is also dying. With more and more people wanting to try and make massive profit from re-selling festives once an event is over, the prices of Strange Festives are dropping. 2014's Strange Festives are falling through the floor, and I will assume that 2015's will be even worse (in price).
AND, with the rising price of keys (and the dropping prices of everything else), trading your keys for metal/the items you want would be the right way to go. Unless my source is wrong, keys are currently at 18 ref and climbing.
In conclusion: you are better off selling your Keys for either the metal to buy the thing you want or trading the Key directly for it. The chance for making profit from unboxing is way too low, and the profits earned from crafting weapons is also too little for the risk involved.
Best Answer
Currently achievable cosmetic items
The following wearables are currently available without having to buy anything on Steam or in the Mann Co. Store.
TF2 achievement items
Other free-to-play game achievement items
Other freely obtainable items not linked to an achievement
Previously distributed items
These hats required no purchases on Steam or the Mann Co. Store, but are no longer available:
Additionally, the Ghastly, Ghastlier, and Ghastlierest Gibuses are no longer available. To see how these hats were originally distributed, read the section on Halloween below.
Event items
Valve usually gives out items during events. Traditionally, these events have coincided with Halloween (near the end of October through the first week of November) and Australian Christmas (near the end of December through the first week of January).
Halloween
There are some items that can only be obtained during Halloween Events. There has been a new Halloween event each year since 2009. Some of these items can technically be gotten year-round on servers that are forced into Halloween Mode by setting
tf_forced_holiday 2
in the server's configuration / console.2009: Haunted Hallowe'en Special
This update introduced the event map koth_harvest_event (Harvest Event).
On top of the original Ghastly Gibus (awarded year-round until being replaced by the Ghostly Gibus in 2012), the first Halloween Special had an additional achievable item:
2010: Scream Fortress
This event introduced the event map cp_manor_event (Mann Manor).
The Scream Fortress event added these items, which were restricted to be only visible during Halloween (or during a full moon, after the 2011 Halloween update):
Crafting one of each of the Class Masks together yields the Saxton Hale Mask, which has no Halloween / Full Moon restriction.
2011: Very Scary Halloween Special
This event introduced the event map koth_viaduct_event (Eyeaduct).
2012: Spectral Halloween Special
This event introduced the event map koth_lakeside_event (Ghost Fort).
Steam events
There's also the Bounty Hat / Treasure Hat / Hat of Undeniable Wealth And Respect, from the Great Steam Treasure Hunt in Winter 2010, and the Summer Shades from the Steam Summer Camp Sale in 2011. These technically didn't require purchases, but they required owning games on Steam and obtaining certain achievements: any three were required for the Summer Shades, including some from free-to-play games, but the Treasure Hunt hats required 5, 15, and all 28 achievements (respectively) in games that ranged from "cheap on sale" to "somewhere around a hundred dollars" (hence the "Hat of Undeniable Wealth And Respect").
In the same vein was the Resurrection Associate Pin, awarded for playing all 13 indie games involved in the Potato Fools' Day ARG leading up to the launch of Portal 2 (the Potato Sack pack). Again, didn't technically require a purchase, but effectively did.
Australian Christmas
During the 2011 Steam Holiday sale, there were three hats (the BMOC, Ebenezer, and Holiday Headcase that could be crafted with 7 pieces of Holiday Coal (Steam items you had a chance of receiving when completing an achievement for the event, in place of a proper gift).
Additionally, the Australian Christmas 2010 event had all players who logged in receive a Stocking Stuffer Key which could open any crate, Holiday or otherwise, meaning that players could potentially receive any hat available in a crate for free.
The Three Moving Hats
There are three hats in TF2 that are held by the player, every day, who scored highest in a particular metric the day before. At the end of the day, the hat is moved from that player to whoever won that day (if the same player scored highest again, they get to keep the hat for another day). These hats are normally tied to amounts of money spent, but only one of them truly requires that you make purchases:
Community accolades
In some instances, Valve has awarded special wearables in recognition of special community members. Many of these are/were for participating in a specific community event (like a contest or a tournament), while others are accolades given out in more or less quantifiable circumstances.
Unique items
Recognitions
Contest participation awards
Steam Workshop
Anybody who contributes a model for an item that gets added to TF2 gets a special "Self-Made" version of that item with the "Community Sparkle" effect.
Tournament Medals
Valve awards medals to participants and winners in various competitive TF2 tournaments:
Non-TF2 tournament non-medals