This is a way to introduce an apology. It's good for use with friends, but also with people you're not as close with. It's used to apologize for something that's you feel a little bit bad about, but not for really serious mistakes.
For a more serious situation, you would stretch out the apology longer. For example:
I have to talk to you about something. I made a really big mistake, and I'm so sorry. (Tell what you did.) Please forgive me.