From what I have read, the Federal Reserve sets the "key rate", which is the rate at which banks can borrow money from the Reserve.
This is called the discount rate, but it is mostly irrelevant, as banks hardly ever borrow from the Federal Reserve system. It is not usually considered to be the key rate.
The more important number that the Fed sets is the federal funds rate target. So let's break this down. Federal funds are the money that the Fed holds as a reserve for banks. Banks must hold 10% of their deposits as reserves. If someone comes in and makes a new deposit, the bank must deposit more money with the Fed but can loan out the other 90%. If a bank is short of 10% and does not have any money to deposit with the Fed, they borrow from other banks.
The rate that banks charge to loan reserves money to another bank is the federal funds interest rate. Each bank may set its own rate. They report the contract to the Fed when they loan the money. The Fed aggregates all the current loans as a weighted average. That average is the federal funds rate that the Fed uses for decision making.
The Fed sets a target for what that rate should be. If the target is missed, they engage in what are called open market operations. If the rate is above the target, they buy treasury bonds from the banks, depositing the proceeds in the banks reserve account. More reserves means more banks trying to lend and fewer trying to borrow. The rate drops, possibly meeting the target. If not, they continue buying bonds.
If the rate is below the target, they do the reverse. They sell bonds, taking the money from the reserves account. Banks have less money in reserves in aggregate, so more need to borrow and fewer have money to lend. The rate increases. If the rate is still below the target, they continue buying.
With all that in mind, let's look back at the discount rate. If banks try to charge too much for reserve loans, borrowing banks have the option of borrowing from the Fed. So they can't charge more than the inconvenience cost above the discount rate when they loan to other banks. The discount rate provides a ceiling for
The higher the interest rate that the bank offers to depositors, the more it is at risk from the prospect of borrowing reserves. Because it will have to pay some interest on the money borrowed. And if it has excess reserves, it will only get a small amount of interest. The net result is that banks usually like to keep their interest rates close to the federal funds rate target. That minimizes the risk of them being stuck paying to borrow or with money that they can only loan to other banks.
Financial papers publish a prime rate for loans. This rate is based on the federal funds rate target. It is a recommendation that the Wall Street Journal creates based on information from banks. It provides a basis for a bank to charge or pay interest rates relative to that rate that provide a profit. Banks generally do not have to charge those rates, but they choose to do so because they work (generate a profit).
There also may be some loans in some jurisdictions where a government (generally federal or state) sets legal limitations on the rate. But most loans are not impacted by those.
Absent legal restrictions, most banks can pay or charge whatever interest they like. But the prime rate is calculated to be the rate at which banks can make money. Most banks just charge relative to it almost all of the time. For example, they may pay an interest rate of prime - 3.5% and charge prime + 1% on a mortgage. The 4.5% between those is what the bank uses to fund its operations (e.g. pay rent and employees) and provide a profit (dividend) to their owners.