A formality is something that follows traditional rules. Even though you knew your request for time off at work would be approved, you still went through the formality of filling out all the required paperwork.
Formality also means to align with customs or etiquette. In this way, a formality is often something that's more symbolic than necessary. For example, when a big group sits down to eat dinner together, no one starts eating until everyone is served. That formality of dining etiquette is a sign of good manners and consideration for others. If you're British, a formality of your culture is to curtsy or bow when you meet the Queen.