In order to begin a discussion about government spending, let's compare two scenarios:
Scenario 1: Let's call this the "eat what you kill" scenario, although the government would prefer to call this the "balanced budget" scenario. In this scenario, the government can only spend what it takes in in taxes in any given year. (This is a bit of an oversimplification since the government can't actually know in advance how much it will collect in taxes, but just go with me here. I suppose this issue could be overcome by spending in a given year what was received in taxes the year before.) The reality of the world is that economic fluctuations exist, and tax revenues are going to be higher in good times and lower in bad times. Therefore, if the government were to match spending to revenue each year, the government would spend more in good times and less in bad times.
Scenario 2: This scenario is basically the opposite of scenario 1. In scenario 2, the government spends more in bad times and less in good times. This means that the government runs a deficit in bad times and a surplus (!!) in good times. (Note that even if the government merely kept spending constant over time it would run a deficit in bad times and a surplus in good times.) Scenario 2 would be designed such that, on average, spending equals taxes, so there wouldn't be a growing debt problem.
Given that the government uses the money it collects to provide services and transfer payments to citizens, the first approach can magnify the ups and downs of economic standard of living rather than mitigate them. To make a household analogy, since the world knows how much I love those, this situation would be as if a dad moved the family into a big house every time business was good and moved the family in to a tiny apartment every time business was bad. This family will likely never be in debt, but this situation seems somehow intuitively unreasonable. In fact, economists typically assume that people prefer consumption that is consistent over time to consumption that fluctuates from day to day or year to year. (And yes, they have data to back up this claim.)
From a utility perspective, then, it's more efficient to have government services be consistent over time than to fluctuate wildly. In addition, it's easier for the public to put their trust and confidence in the government when they can be reasonably certain that what they get from the government today won't be taken away tomorrow. (I think it was Austan Goolsbee who recently pointed out that confidence is the cheapest form of stimulus, and there's certainly something to be said for that notion.) That in itself is a decent argument for scenario 2 over scenario 1, but is there more?
One of the arguments against government spending as stimulus is that it crowds out private investment. This happens because the US usually has to borrow, i.e. issue Treasury bonds, to finance the deficit, and having the government throw its hat into the borrowing ring makes it more expensive for private companies to borrow. (In other words, increasing the demand for borrowing increases the price of borrowing, namely the interest rate.) Therefore, government attempts to stimulate the economy via deficit-financed spending makes it harder for private firms to do their parts to get the economy back on track.
Another argument against spending as stimulus is that, by employing people to complete public projects, the government is taking them away from potential private-sector employment. However, isn't it during recessions that there are a whole bunch of unemployed people lying around? Therefore, it stands to reason that economic downturns are actually a better rather than a worse time to hire people for government projects.
This last point, in addition to the fact that people like consistency as well as the observation that interest rates are often low during recessions (which addresses the crowding-out problem), implies that scenario 2 is logistically superior to scenario 1. Simply put, if a government has discretion over when to undertake some of its projects (repairing roads and building new roads and such, for example), doesn't it make sense, on multiple levels, to undertake these projects when people are otherwise unoccupied and the economy could use the help?
The government seems to abide by this principle on some level, since there is a decent chunk of spending that falls under the category of what are known as automatic stabilizers. Automatic stabilizers are government payments that go up in economic downturns and go down during economic booms without the government explicitly having to decide on such payments. Unemployment and welfare transfer payments are prime examples of automatic stabilizers, despite the fact that they weren't necessarily introduced for that purpose.
Before you get all ideologically upset, note that this discussion is only about the timing of government spending and not about the overall level of spending. Note also that deficit spending during a recession implies that the government has to run a surplus during good times in order to avoid running up a constantly increasing debt. From a political perspective, however, it's apparently pretty tough to commit to running surpluses in order to save up for the rainy day spending.