Use of steroids in this fashion was not only cheating, it was illegal. There are no rules against having someone break your opponents leg before a big game because we don't need rules to prevent that. The same with steroids. Their use was illegal, even if baseball had no explicit rule against them. But then drinking was illegal for a long time while baseball players, including Babe Ruth, were well-known for their love of demon-rum (and whiskey and beer and ...). The difference with steroids is that players who used them got a huge advantage over players who didn't. So we don't rule out players who break the law.
So if using steroids isn't an automatic HOF rejection, why not McGwire? Because his only real HOF credential is his breaking Maris's record and his ranking among career home run leaders. Both of those "accomplishments" are clearly the result of steroid abuse. Absent McGwire's late life steroid induced home run binge, he would be remembered as a guy who was never able to repeat the year he had when he broke in.
By contrast, Barry Bonds was already a Hall of Fame certainty, even before his obvious foray into steroid abuse gave him the home run records. His only major handicap was his surly reputation with the media who vote for the Hall of Fame.
Perhaps the most telling testimony in Bonds trial was by his former long-time girlfriend as she described the effects steroids had on him. The changes in mood, the injuries, shrinking testicals, acne etc. More than anything it made the case for why steroid abuse is banned. It demonstrated clearly the cost to players if they are forced to use drugs in order to compete with those that do. Bonds in many ways is a perfect example. It appears he took up steroids to show the world he was a better player than his long time Bay are rival, Mark McGwire.
In some ways, Bonds is as much a victim of the steroid era as he was one of its perpetrators.