Interest rates are set by a countries central bank, here in the US, that is the Federal Reserve. They set the Fed funds rate which is basically the rate at which banks can borrow money. Banks in turn, lend that money out after they mark it up for a profit. Simple.
When times are good and getting better, the Fed raises interest rates to slow inflation.
When times are bad and getting worse, the Fed lowers interest rates to spur the economy.
The relation of interest rates to the stock market is not simple, it is very complex to say the least. When interest rates on fixed income such as CD's, US Treasuries and corporate bonds are relatively high, investors tend to take on less risk which can put pressure on stocks however, increasing interest usually means times are getting better which means public companies profits are stronger and thus their stock price should reflect those profits and increased cash flow. But corporations borrow money too and increased borrowing costs will affect companies profits and thus their stock price.
As you can see, the relation of interest rates to the stock market is very complex to say the least. Hopefully this very brief overview has been helpful.