If we really want to make a steroid analogy, it should be to people who actually productively lift heavy object. Let's say it's movers, for the sake of analogy. There is a competitive angle to being a mover, of course. If you're stronger, and therefor better able to maneuver a client's grandmother's heavy china cabinet down the winding stairwell in a controlled manner, you're more likely to get hired than a bunch of wimps. So you're getting a competitive leg up by using steroids. But it's not just a useless arms race. If every mover did steroids, than people's stuff would get moved better, and the population of people who have heavy and bulky stuff to move would be much better served. So there is some wider benefit. Whether or not this benefit is enough to counteract the health costs associated with the side effects of the steroids is an important issue to figure out (and in fact, I think it isn't by a pretty large margin), but in principle if the side effects were small enough and the value of having beefy movers big enough, it could be worth it.
I think the baseball analogy fails because baseball is a competition for competition's sake. If steroids made every player 20% better, then they'd still all be in the same place with respect to each other, and no one would be better off. A baseball player who uses steroids, then, benefits only because he gets a leg up on the competition, and not because he's any more effective at accomplishing anything of real value. There's no benefit in hitting a ball a few dozen yards further, except insofar as you're hitting it further than your competition. Even if near perfect steroids could be made, that increased strength with almost no adverse health risks, we would still consider them an unfair advantage.
If a drug helps medical students to learn more, learn faster, learn better, or just spend more time studying and less sleeping, it puts them at a competitive advantage to their peers, but it may also help them learn to be better doctors. And there's a real benefit to having better doctors. If every med student were to take such a drug, then in principle everyone would be better off. The important question becomes, what are the costs or risks of a drug, and how do they compare to the benefits? For some drugs, like caffeine, many people agree that the not-insubstantial benefits far outweigh the relatively innocuous and minor risks, and so we allow, and often even encourage, widespread use. For other drugs, like, say, methamphetamines the potential benefits are far outweighed by the adverse health effects, addictiveness, and potential for abuse, so we discourage their use. In principle, though, if some alternate form of meth could be discovered with a great effect on attention and learning with almost no side effects, we would be fools not to encourage students to use it.