So with Cell A1 = profit 1 and Cell A2 = profit 2, put this in a convenient cell to work out the profit percentage (lets take A3):
=((A2-A1)/A1)*100
You can format this to give a rounded figure, but that doesn't make a big difference to the rest of the calculation, just makes it easier to read. Now take another convenient cell (A4 in this case) and put this in there:
=IF(A3<=10;5;IF(A3<=20;10;IF(A3<=30;15;IF(A3<=40;20;25))))
It is a nested IF function that first checks if the profit is below or equal to 10 percent, if so it delivers the number 5, if not it moves to the next IF statement which checks if the profit is below or equal to 20 percent, delivering the number 10 if so, and so on. The last one checks if the profit is below 40 and delivers 20 if so, if not then it delivers the number 25.
Now you can take the result of this function and use this to calculate the amount you want to pay. Put this in A5 for example:
=(A4*0,01)*(A2-A1)
(If your computer is configured to use a dot as a decimal separator then change this in the last formula.)
You could of course combine everything into one big formula, for example you could take the first formula and substitute that for every instance of 'A3' in the next formula and do the same with the results (0,05*(A2-A1) instead of the number 5 and so on). By spreading the calculation across a few cells it is somewhat easier to follow and it may help avoid mistakes.
Edit: I just noticed that an extra space appears in the second formula, in the last bit there is a space between the 2 and the 0 of the number 20. I cannot get it out it seems to you'll have to edit that after copying the formula.