https://en.wikipedia.org/wiki/Surety

A surety most typically requires a guarantor when the ability of the primary obligor or principal to perform its obligations to the obligee (counterparty) under a contract is in question, or when there is some public or private interest which requires protection from the consequences of the principal's default or delinquency. In most common-law jurisdictions, a contract of suretyship is subject to the Statute of Frauds (or its equivalent local laws) and is only enforceable if recorded in writing and signed by the surety and by the principal.

If the surety is required to pay or perform due to the principal's failure to do so, the law will usually give the surety a right of subrogation, allowing the surety to "step into the shoes of" the principal and use his (the surety's) contractual rights to recover the cost of making payment or performing on the principal's behalf, even in the absence of an express agreement to that effect between the surety and the principal.