Credit risk is the risk of the issuer of the bond defaulting on its issued bonds, i.e. not being able to pay all or part of the maturity value and/or the interest on the bond. It is common wisdom that government bonds are risk-free, i.e. that governments never default on their issues of securities. This is not necessarily factual.
However, when countries are stable politically and economically, it is almost impossible for their governments to default on their debt. Thus in the stable parts of the world the rates on government securities are regarded as risk-free rates. All other rates on bonds are referenced on these risk-free rates.
The rates on a non-central government bonds are made up of two elements: the risk-free rate and the risk premium. The latter is the premium paid by the non-government issuer at issue (demanded by the buyer at issue and in the secondary market) as compensation for taking on a measure of the risk of default.
In mature bond markets non-central government issuers of bonds have their bonds rated by a rating agency (and possibly by more than one agency). Investors rely on the ratings of the credit rating agencies to gauge the quality of the borrower and to “set” the risk-premium demanded.