I would say that there are two purposes for bail -- one that is meant to be of help to the defendant and one that is meant to help the state.
When a person is charged with a crime, he or she may be allowed to stay out of jail after having posted bail. By posting bail, this defendant is allowed to get on with his or her life. The defendant does not have to stay in jail awaiting trial -- this is clearly a benefit to the defendant.
The state is benefitted by bail because the posting of bail helps to ensure that the accused will appear for the trial. This is in the interest of the state. (It is also useful to the state to avoid having to pay for the upkeep of the accused in jail while awaiting trial).