The government shut down for 16 days in October 2013 because the House and Senate couldn't agree on legislation to fund the government, and time ran out. At the start of the fiscal year, on Oct. 1, 2013, neither an appropriations bill, nor a continuing resolution had passed in Congress.
Leading up to the shutdown, the Republican-controlled House of Representatives, heavily influenced by Tea Party groups and conservative activists, made funding of the government contingent on defunding Obamacare, something the Senate refused to agree to. In September 2013, the House of Representatives proposed their own appropriations bill which proposed deep cuts in the Obamacare. The Senate sent the bill back without the provisions about Obamacare, but the House of Representatives refused to agree and also refused to agree to a continuing resolution, when their final offer that the Senate agree to delay implementation of Obamacare failed.
Congress controls government spending, known as appropriations legislation. When budget negotiations break down, Congress often passes continuing resolutions that extend current spending at or near the then-current spending levels. When a funding gap results, the Antideficiency Act requires non-excepted government functions to shut down immediately so that the constitutional authority of Congress over spending is not breached.