Zorro, The Gay Blade

Set in an indeterminate year of the 1840s, the film opens in a villa in Madrid, Spain, where Don Diego de la Vega (George Hamilton), the archetypal Spanish Don Juan, is in bed with a beautiful woman who, we learn shortly, is not his wife, but someone else's. The couple are caught by her husband, Garcia, who "is not in Barcelona", as they had previously thought. Diego, with considerable panache, fights Garcia and his five brothers with swords. During the fight, Diego's mute servant Paco (Donovan Scott) reads a letter (via gestures) from Diego's father requesting that Diego return to California [then a part of Mexico]. Diego and Paco escape by jumping from a high wall directly into a waiting carriage.
Diego and Paco arrive in Los Angeles, where they are met by Diego's childhood friend Esteban (Ron Leibman), who has become capitÃ¡n of the local guard. We also learn that Esteban has married Florinda (Brenda Vaccaro), for whom the men competed when they were boys.
Esteban delivers the sad news that Diego's father was killed in a riding accident, when his horse was frightened by a turtle. Esteban is acting alcalde in the senior de la Vega's stead until a new one can be chosen by the dons (landowners) of the area.
At the meeting of the dons, each introduces himself and where he resides. Each Don's surname is that of a well-known city in California, but none of the surnames and place-names match, with amusing results:

Don Diego from San Fernando
Don Francisco from San Jose
Don Fernando from San Diego
Don Jose from San Bernardino
Don Luis Obispo from Bakersfield, who wears an ascot
Esteban is elected alcalde, via an obviously fixed election, and gives his inaugural speech to the assembled peasants in the village plaza. He is interrupted mid-speech by Charlotte Taylor-Wilson (Lauren Hutton), a wealthy political activist from Boston. She and Diego meet, and despite their political differences, there is an immediate attraction.
Relaxing at the de la Vega villa, Diego receives an invitation to a masked ball to celebrate Esteban's election. He is also given his inheritance, which turns out to be Zorro's black cape, hat and sword. A note from his father tells Diego the truth: his father was Zorro. Diego decides that it is the perfect costume for the ball.
On the way to the ball, Diego witnesses a peasant being robbed by a criminal. Giving chase, Diego confronts and defeats the highwayman, and returns the money to the peasant, instructing him to spread the news that El Zorro has returned.
At the ball, Diego (under cover of anonymity) dances with Florinda while the old peasant informs the people outside that Zorro has indeed returned. At the same time, we learn that the robber was in fact Velasquez, the area's tax collector, who reports the theft to Alcalde Esteban â and points out Diego. A duel ensues, and Diego escapes by again jumping from a high wall, but injures his right foot in the process. Unable to walk without a noticeable limp, he hobbles away. Esteban and Velasquez plan to use the injury to track Zorro down.
Later that night, a drunk Florinda attempts to seduce Diego in his bedroom, but Esteban arrives to speak about the events of the evening. Esteban begins to suspect that Diego is Zorro, but Diego is able to convince him that his foot is not injured. Esteban leaves, satisfied.
A reign of terror begins, including wholesale torture and increased taxation. Diego is frustrated that, because of his injury, he cannot fulfill his destiny as Zorro. Enter Diego's fey, foppish and British-educated twin brother Ramon Vega (Hamilton in a dual role), who joined the Royal Navy and adopted the pseudonym Bunny Wigglesworth. Diego brings Bunny up to date on what has been happening, and Bunny agrees to stand in as Zorro â using a whip instead of a sword, and with gaily colorful costumes.
Zorro continues to elude capture, much to the anger of Esteban and the dons. Esteban hatches a plan to lure Zorro to the alcalde's residence by throwing another ball to show off Florinda's expensive new necklace. Seeing through the plan, Diego arrives, dressed as Zorro â and so do the rest of the dons and male party guests, telling Esteban that a mysterious servant instructed them to dress as Zorro. Adding to the confusion, Bunny appears in drag, masquerading as "Margarita" Wigglesworth, Diego's cousin from Santa Barbara. Esteban is smitten and calls her "Wiggy". Bunny succeeds in spilling a drink on Florinda, and in the resulting attempts to clean her dress, makes off with the necklace. Bunny then returns to the Royal Navy, informing Diego that Charlotte Taylor-Wilson is in love with Zorro.
Diego and Charlotte confess their love for each other at the plaza, but they are seen by an operative of Esteban's. Esteban has her arrested and sentenced to death to again lure Zorro to capture. At the last moment, Diego surrenders to Esteban in order to save Charlotte. Zorro is immediately sentenced to death.
Seconds before Diego is to be shot, Bunny returns to free his brother, and with Charlotte's aid they finally incite the peasants to rebellion. Esteban's own guards rebel as well, and at the end even Florinda turns against her husband. Esteban is defeated. Bunny rides off to catch his ship to return to England, and Diego and Charlotte ride off to settle in Boston and to plan their wedding.

Question: For what purpose was the masked ball being given?
Answer: Esteban's election