I noticed that the interest rate on excess reserves and the fed funds rate are almost exactly the same at all times. Why is this the case? Shouldn't the credit risk of a bank be higher than the Federal reserve and shouldn't this premium be reflected in the Fed Funds rate?
Actually the IOER has slightly exceeded the Fed Funds rate in recent years. Currently IOER is 10bp and FF last set at 8bp for example. During the period 2009 to 2015, IOER was set at 25bp and FF averaged about 13bp. So what is going on? The FOMC sets IOER as a matter of policy , but FF is set by supply and demand for overnight loans between financial institutions in the Fed system. In this era of excess reserves , many financial institutions have excess cash, so the problem is to lend it at the best rate. The problem is that not all institutions can access IOER, because it is for depository banks only , so there is additional cash to invest held by others, such as the Federal agencies (home loan banks) for example. They invest in overnight Fed funds, driving the rate down below IOER. A bank could (and some do) borrow at these lower rates to invest in IOER, locking in a few bp.
Thus, the spread is driven by considerations of supply and demand rather than credit risk.
Both federal funds rate and rate on excess reserves are determined by Fed's Federal Open Market Committee (FOMC). These rates are not set by the market but by the decision of the Fed, which depends on their monetary policy. They are equal because FOMC set them to be equal.