I disagree with some of the people above.
Say you have a 12 month lease signed with a tenant for $1000 a month in rent and a $1000 security deposit. If they break the lease and decide to leave after 3 months, that means $9000 is still due to you. You could either sue them for that entire amount (usually not worth it because most tenants don't have surplus cash) or keep their deposit as damages and not sue them (basically allowing them to settle).
The deposit serves two purposes, to encourage them to keep the property in good shape and to not take off and abandon the agreement. Remember, the lease is a legally binding contract. The moment they sign, they are on the hook for $12,000 paid over 1 year and you are on the hook for giving up possession rights to your property. That's contractual.
The only way a tenant can break a lease early is if you agree to it. As long as you don't agree, then you can either sue them for the balance of the term or essentially keep their deposit as an agreement not to sue them for the remaining $9000.
When I have tenants break their lease early I keep their deposit and don't deal with the time or effort of pursuing the lease balance in court.
Good Luck.