"Risk-Free" Is an Approximation

The assumption that developed-market government bonds are risk-free is useful but not literally true. History contains numerous sovereign defaults. Russia defaulted on its domestic rouble-denominated debt in 1998, triggering a global financial shock that contributed to the collapse of Long-Term Capital Management. Argentina has defaulted multiple times — most spectacularly in 2001, when it restructured $100 billion of debt at deep discounts. Even within the eurozone, Greece required two restructurings in 2010–2012, imposing significant losses on private bondholders.
Credit rating agencies — S&P (which began rating sovereigns formally in 1916), Moody's (founded 1909), and Fitch — assign ratings to governments just as they do to companies. A downgrade can move market yields significantly.