I agree to the person a few posts above, I never rated Tom Hanks performance in Philadelphia. I would go as far as saying it's one of the weakest performances I have seen him do. Denzel gave the better performance
I don't necessarily agree about Denzel, his was definitely the more showy role but I've seen him a lot better in a lot of other things.
I think Hanks's win though is down to context. At the time gay rights was a much discussed issue particularly in the US after Clinton had attempted to overturn the ban on openly gay people serving in the armed forces. Added to that HIV was at that time a major issue with huge amounts of misinformation around. So given that gay rights and HIV were such hot button issues it's not surprising the Academy gave an award to someone in a film dealing with and portraying someone coping with those issues. IMHO they did the same in 2009 when they awarded Penn the Oscar for Milk after the passage of proposition 8 the November before as almost a way of saying that the Academy didn't approve.
I think as well you have to consider the fact that it was Tom Hanks playing the role. At the time Hanks was a relatively young actor who had made his name in comic roles and rom-coms (with the odd exception). So Philadelphia was a huge departure from the norm for him and potentially risky given the issues dealt with. A role like that could possibly have backfired and made him unhirable for some projects which wasn't true for Denzel who'd tended to be involved in films with more edgy subject matters. Plus I don't think without Philadelphia he would have gone on to do some later stuff like Saving Private Ryan.
So rightly or wrongly I think in giving Hanks the Oscar the Academy were responding to current events and rewarding him for his perceived bravery in taking in the role.
And don't forget if Hanks hadn't won we'd never have the wonderful In and Out (well wonderful in my opinion anyway!)