Pardon = (formal) forgive; the act of excusing a mistake: I’m sure they will pardon the occasional mistake.
Excuse = give someone permission to stay away from school, work etc., or leave a classroom, meeting etc.: Can I be excused from swimming today please?
I beg your pardon is used (1) to apologize to a stranger because you have bumped into them by accident, sat in their seat by mistake, etc.: I beg your pardon. I didn’t know the table was reserved. (2) to politely ask someone to repeat what they have said: Does this bus go to Marble Arch?I beg your pardon? (3) when someone has said something that makes you feel surprised, shocked, angry etc.: Who’s that woman with long hair?I beg your pardon! That happens to be my wife.
In formal situations, you can use excuse/forgive me instead of I’m sorry: Please excuse me for taking so long to answer your letter.