The debits and credits must be equal because every transaction has two entries, one on each side. The total of the debits must always equal the total of the credits for that transaction.
If the debits and credits don’t balance, it means that there is an error in the bookkeeping and the entry won’t be accepted. Therefore, most modern accounting software will only let you submit the entry if the debits and credits do balance.