As Poe put nothing unintentional into his work, famously stating that every word had its purpose, we should assume that Montresor's statement that he belongs to the society of Freemasons has a meaning in the text. This is probably twofold:
Firstly, it foreshadows Fortunato's cruel death by live burial. The builder's trowel is a famous Masonic symbol. The fact that Montresor chooses to bring up the Freemasons and by doing so reveals the instruments of Fortunato's murder may show his eagerness to do the deed. Disguising it as an innocent Masonic symbol is his excuse to reveal the murder 'weapon', so to speak. Many killers are proud of their handiwork, with most believing they have committed the perfect crime. Montresor was probably no exception, as we see he cannot keep his crime to himself by the very telling of this story. The presence of the trowel thus serves to foreshadow the story's end and reveal Montresor's nature as a calculated killer.
Secondly, the dialogue between Fortunato and Montresor when discussing the secret and exclusive society of the Freemasons could also serve to demonstrate the men's relationship. Montresor never explicitly details the many injuries Fortunato has inflicted on his ego, but perhaps the slight of suggesting Montresor couldn't be a member of the Freemasons is such an example:
“You? Impossible! A mason?”
Even after Montresor insists and shows the trowel as proof, Fortunato is still disbelieving, saying,
“You jest... But let us proceed to the Amontillado.” (eNotes etext p.7)
We could take this as proof that Fortunato holds Montresor in no high regard, which surely frustrates the latter to the point of detesting the former. With a bruised enough ego from a thousand injuries (and perhaps a damaged psyche), Montresor has enough motive to plan Fortunato's death. Therefore, Poe might have inserted this bit of dialogue as an example of Fortunato's insulting demeanor. Montresor is exacting his revenge, but in order for that to be plausible we have to see what drives him to that extreme.
We may not know for certain to what end Poe included this mention of the Freemasons in "The Cask of Amontillado" but by analysis it seems to reveal a bit more of the nature of both characters of the story--one as a methodical killer, the other as his worthy victim.