UBI isn't expensive. Its wealth redistribution, not consumption. Military spending is a black hole of money - you get very little R&D or productive GDP growth yields out of it but it stucks hundreds of billions out of the country every year. Social security is better than military spending but usually worse than UBI - recipients of social security are some of the richest people right now as an age class, so transferring wealth to them often doesn't see it stimulating economic growth - it just gets reinvested. Additionally, social security taxes are not progressive - they cap out, and anyone making any money over 10k is paying into them. Its a regressive tax scheme that takes money from disproportionately the working poor and moves it into a richer age group.

It still isn't a black hole, though. A ton of social security money is then spent on essentials. Its much less wasteful than defense spending.

On the other end of the spectrum is a lot of infrastructure spending, especially big projects like Eisenhowers national highway system that built the interstates - money goes in, but the productive gains and economic stimulant from the spending is greater than the money going in so it is a net positive for the economy. I'm hesitant to even call that government spending or debt or the cost of the state since it doesn't really cost anything - you are using money to make money. It is state investment.

Now, of course, state investments have variable success rates. You can look back at successful projects and say they were obviously worth doing in hindsight because they have produced substantial prosperity. The highway system, the national railroads, the panama canal, national electrification, the Hoover dam, etc have all proven valuable. But often a bridge built or rails laid go unused and were wasteful. And then there is the matter of how bad the government is at keeping these projects within sane budets - Boston's Big Dig took significantly longer and cost multiple times more than initially projected, and that brings the value into question after its done whereas beforehand it looked obviously beneficial.

UBI I think is in a very optimal spot on that spectrum. It is immediate wealth redistribution, going almost exclusively to the poorest who per dollar earned spend the most of directly stimulating economic demand that grows the economy most optimally. But unlike infrastructure investment the return is immediate - as checks go out money is spent often same day, and as long as money is moving from slow growth (investment) to fast growth (consumption) its a net benefit to the economy, as long as said benefit is greater than the overhead of administrating the taxes to fund it and the distribution of the money. Which comes back to the infrastructure is great scenario - its great until you are being wasteful and corrupt in spending on it. If money is actually going to building infrastructure or money is actually going to the poor it is a colossal boon. When money goes into private pockets as it does in spades with the DoD it is wasteful. It isn't the amounts you take, it is how you spend that, and how predictable your spending and taxing will be going forward - markets can handle very high taxes as long as they are predictable.