Government debt arises as a result of the issue of government bonds.
Government bonds are issued by a country in order to finance investments without raising taxes. In principle, that's a smart idea, if you think about it.
That's how it works (simple case): Government issues bonds at 95$ today promising it will buy them back the following year at 100$. The difference between the two numbers (100-95=5$) is the interest, which, if divided by the issue price, reveals the interest rate (5/95=5,26%).
Everyone can buy government bonds: banks, companies, but also ordinary people like you and I.
Bond subscribers therefore lend money to the state and become creditors. Government, on the opposite, contracts a debt that must be paid for in due time.