why does the government sell bonds
Governments sometimes spend more money than they take in in revenue. That may be because the economy is in recession and tax receipts are down, or because they cut taxes below what they want or need to spend on. There are other reasons, like national crises. When that happens they have to borrow. To borrow they sell bonds. In the US these are known as Treasuries, but other countries have different names. For example, in the U.K. they are known as Gilts and in Germany they are known as Bunds.