During the movie, Melvin is very neurotic and has a tendency to either say the wrong thing, or say something that is just off. He has said offensive things to Simon in the past.
In this scene, near the end, Melvin, by saying I tell you buddy, I'd be the luckiest guy alive if that did it for me, does three things. He calls Simon buddy, acknowledging he is his friend. He would be lucky, because the gay character is a great person. He loves him also, just not in a romantic way, but can't quite say this. And by comparing himself to a hypothetical gay person, without any offensive comments, it shows deep down he has no real prejudice.