Ok, imagine you have a really cool club that you're in with all your friends. This club has some really important rules that everyone has to follow so that everyone can have fun and be friends.
One of these rules is that everyone has to promise to be loyal to the club and always do what's best for it.
The Oath of Allegiance is like making a really serious promise to be loyal to a club or group that you really care about. In the United Kingdom, when people become citizens, they take the Oath of Allegiance to promise to be loyal to the Queen and obey her as the leader of the country. It's a way of showing that they are committed to being a good citizen and following the rules of the country.
It's like if you were joining a secret club and you had to say "I promise to always be a good member of this club and follow the rules". The Oath of Allegiance is the adult version of that.