A good farewell speech has four elements. First: a personal opening that immediately shows you really know the person. Not 'we are gathered here tonight', but a concrete memory or observation. Second: an anecdote, something funny, touching or typical of this person. That is what people remember.
Third: honest appreciation. Not a list of job titles. Rather a concrete compliment about what this person has meant to the organisation or the team. And fourth: a sincere wish for the next phase. Keep the speech between three and five minutes. Longer, and you lose the room. Shorter, and it feels fleeting. Practise it aloud beforehand, not from memory, but with notes as a guide.