It's not particularly simple but for various reasons I've looked closely at how this stuff works.
The first problem is that the "Cost of Funds to the Bank" is not the interest rate you pay for the loan - it's a "wholesale" interest rate set centrally by the banks treasury department. The branch then adds a one or two percent for their profit when they quote you a rate. Thus you are unlikely to verify the formula externally as you will not know what this internal "non-retail" interest rate is. However without getting into too much detail, these rates will very closely mirror those of the markets.
Another subtlety is that fixed interest rates also vary by term - called the yield curve; borrowing for longer normally incurs higher interest. There are two separate interest rates involved in the breakage fee calculation - the original rate when the loan was taken out is for the full term (e.g. a 5 year fixed rate) and the rate for the remainder of the term (e.g. say you decide to break the loan 2 years in, this will be the 3 year rate at the time of the breakage).
The easiest way to understand how this stuff works is to think in terms of the bank branch simply being a retailer for wholesale fixed term borrowings.
It is also far simpler to work through an example using an interest-only loan/mortgage instead of a regular mortgage. It works the same in both cases.
Say you borrow 100k interest-only at 5% for 5 years fixed but after 2 years you want to pay back the 100k early. Conceptually, what happens is that the branch originally borrowed 100k on your behalf for 5 years; at the time of your loan, the wholesale 5 year rate was 3.5% so the bank branch can expect the customer to pay 5k a year out of which it pays the 3.5k and pockets the 1.5k as profit. However the bank branch is completely locked into this repayment schedule - unlike the customer who can redeem the loan early. So no matter what, they have to pay 3.5k a year (as well as the 100k at the end since this is interest only).
When you subsequently break the term after two years, the bank branch is still stuck with the original 3.5k/year repayment schedule for the rest of the term (3 years). The nature of the wholesale loan is that it cannot be repaid early.
So how can the bank allow you to pay off the loan early at all? It is a little counter-intuitive; when you arrive with your 100k to pay off the loan early, the bank branch takes the 100k early repayment and invests it in the money markets getting a 3 year fixed rate. If the current 3 year interest rate is higher than the original 5 year rate (e.g. the 3 year wholesale rate is now 4.5%), then the interest it earns on LENDING the 100k to the markets (4.5k a year) will cover the 3.5k it has to come up with to pay for the original loan. Now the bank branch won't necessarily be delighted - remember they were making 1.5k a year profit before and now they're only making 1k but at least they're not losing money so they do not charge you a breakage fee. We can ignore this case.
However, if interest rates have dropped and the three year rate is now only say 1.5%, then the bank branch can only make 1.5k a year by investing the 100k which was redeemed early. This leaves them with a shortfall of 2k a year to pay off the 3.5k on the original wholesale loan. There are 3 years left in the loan, so this gives you a total shortfall of 6k. This is actually a real cost for the branch and so they recover it using a "breakage fee".
Looking at the quoted formula, with the above figures, we have:
A is 3.5%
B (3 year fixed rate) has dropped to 1.5%
C is three years.
D is 100k
Thus they will charge you (3.5% - 1.5%) * 3 years * 100K which is 2% * 3 * 100,000 which is 6K which matches what I derived above without using the formula.
Note that this explanation is conceptual.