Why would an arahant mention that he is one and does the texts say anything about the purpose of mentioning that one is an arahant?
I think the Buddha said he was an Arahant. The Ariyapariyesana Sutta says,
"Then, wandering by stages, I arrived at Varanasi, at the Deer Park in Isipatana, to where the group of five monks were staying. From afar they saw me coming and, on seeing me, made a pact with one another, (saying,) 'Friends, here comes Gotama the contemplative: living luxuriously, straying from his exertion, backsliding into abundance. He doesn't deserve to be bowed down to, to be greeted by standing up, or to have his robe & bowl received. Still, a seat should be set out; if he wants to, he can sit down.' But as I approached, they were unable to keep to their pact. One, standing up to greet me, received my robe & bowl. Another spread out a seat. Another set out water for washing my feet. However, they addressed me by name and as 'friend.'
"So I said to them, 'Don't address the Tathagata by name and as "friend." The Tathagata, friends, is a worthy one, rightly self-awakened. Lend ear, friends: the Deathless has been attained. I will instruct you. I will teach you the Dhamma. Practicing as instructed, you will in no long time reach & remain in the supreme goal of the holy life for which clansmen rightly go forth from home into homelessness, knowing & realizing it for yourselves in the here & now.'
The book In the Buddha's Words by Bhikkhu Bodhi translates "is a worthy one" in this sentence as "is an Arahant",
"Thereupon I told them: 'Monks, do not address the Tathagata by name and as "friend." The Tathagata is an Arahant, a Perfectly Enlightened One. Listen, monks, the Deathless has been attained. I shall instruct you, I shall teach you the Dhamma. Practicing as you are instructed, by realizing it for yourselves here and now through direct knowledge you will soon enter and dwell in that supreme goal of the holy life for the sake of which clansmen rightly go forth from the home life into homelessness.'
I suppose the reason was to persuade the five to listen to his teaching, to benefit them.
FYI page 136 of The Patimokkha Training Rules Translated and Explained,
This would have led some people to remain secretly convinced of Ven. Dabba Mallaputta’s guilt and—because he was an arahant—would have been for their long-term detriment and harm.
... which might imply that someone who is (secretly or not-so-secretly) against an arahant would be so to their detriment. So might that perhaps be another reason for an aharant's "revelation"?
Page 86 through 98 explains the following rule,
Should any bhikkhu, without direct knowledge, claim a superior human state, a truly noble knowledge and vision, as present in himself, saying, “Thus do I know; thus do I see,” such that regardless of whether or not he is cross-examined on a later occasion, he—being remorseful and desirous of purification—might say, “Friends, not knowing, I said I know; not seeing, I said I see—vainly, falsely, idly,” unless it was from overestimation, he also is defeated and no longer in affiliation.
So I suppose the rule is to forbid knowingly lying about it.
There might be another rule for not saying such a thing to a lay person (page 92),
Claiming a superior human state that one mistakenly thinks one has achieved is no offense under this rule, although if addressed to a lay person the claim would come under Pc 8.
Note that "superior human state" is not just "being an aharant" but also attainments of jhana, samadhi, fruits of the path, abandoning defilements, being free from hindrances, etc.