There are two parts to this question: 1) Is OIS a good risk-free proxy? and 2) Why is OIS used to discount cash flows of derivatives.
First, overnight indexed swaps, in the US, are indexed to the Fed funds effective rate, which in turn tracks the Fed funds target rate. The Fed Fund target rate is directly set by the Federal Reserve, while the Fed Funds effective rate is determined by supply/demand in the Fed funds market. The dynamics of the Fed funds market are completely different from private sector interest rate markets, because the Fed directly influences/manages the supply/demand in this market. In fact, it is the NY Fed's job to ensure that Fed funds effective rate more or less tracks the target rate through open market operations; otherwise, it would be very difficult for the Fed to conduct its monetary policies. Consider what happens when the economy is in distress. The private interbank market may demand increasingly higher credit risk premium and banks may face substantial funding pressures, but the Fed in such a scenario will almost certainly lower the Fed funds target rate. The NY Fed will do its job and make sure Fed funds effective rate go down accordingly. All of these statements are meant to paint this picture – you might as well forget about the individual participants; just think of Fed Funds effective rate as a rate controlled by the Fed. (This is a strong statement today, given the evolution of the Funds market after the financial crisis, but this nuance is better suited for a separate discussion.) As a result, OIS, whose payoffs are determined by Fed funds, does not price in credit risks AT ALL, but simply reflects market's expectation for future Fed funds rate (i.e., Fed's future monetary policy stance) and some term premium for longer tenors. If you go back and look at what happened after the Lehman bankcrupty, the Fed funds market was well functioned and reserve expanded. This is why FRA/OIS spread went to extreme levels at the time – FRA moved a lot because of stress in the private interbank mkt, OIS didn't skyrocket because the Fed was busy cutting rates to 0.
The next topic is OIS for discounting cash flows of derivatives. This is only true for collateralized derivatives where the collaterals earn Fed funds effective rate. If you enter into a swap where the collateral earns a different rate, you shouldn't use OIS discounting! The problem during the financial crisis was that derivative PVs were calculated using LIBOR, which was higher than the returns earned on collaterals (typically Fed funds effective rate). As a result, the PVs used to determine how much collateral was required ended up being too low (because of the higher discount rates). When counterparties began failing, people woke up to realize that there wasn't enough collaterals to cover the losses. OIS discounting closes the gap.
As an additional comment (and as @dm63 has articulated above), Treasuries are heavily influenced by supply/demand factors, while swaps have unlimited supplies. Because of balance sheet pressures after the financial crisis, longer dated Treasuries have routined traded cheap relative to swaps. As a result, OIS actually provides a clearer measure of future interest rate expectations.
Another advantage of using the OIS is that people from different banks more or less agree on how to build it, while different banks build wildly different Treasury curves.