You typically don't put up the full amount, maybe 5-10%. The rest of the risk of you not showing up for your trial is assumed by the bail-bondsman or some other intermediary. Since people usually show up it is a good business.
As an aside, the problem with this system-- like a lot of the US justice system-- is that it favors people with wealth.