When a person is arrested and faces criminal charges that may result in jail time, there is often a lengthy period of time between the initial arrest and the trial. During the time between your arrest and the eventual trial, bail can be posted, allowing you to remain free until trial.
People post bail by paying money as a guarantee that they will not flee the area and that they will return for the trial. As long as the offender out on bail appears in court for trial, the money is returned. If the defendant does not return to the court, the bail money is forfeited.