Bail is a refundable money which is given by the person to the court. When a person is arrest and charged with a crime they must in the jail until the bail hearing. At the hearing the judge will set the bail amount, if the person cannot afford his freedom they must wait in the jail until their court date.
Not everyone accused in any charges will be granted the freedom there are few charges which are non-bail able that depends on countries judiciary law. Its a refundable deposit which a person gives to the court as his security that he will be back for his hearing and will not hide. If the person is unable to be in the court on decided date, then this mean you forfeit the money and an arrest warrant will be generated on your name.
Giving suspects freedom until their trail is in major aspect of the legal concept in a sentence until proven guilty. However, if you are unable to afford your freedom you stay in prison until your trail or you can hire freedom agents which can charge you 10% to 15% of the bail amount.