I believe the song is about the trials and tribulations of hard drug use and addiction. Ozzy liked his drugs and would do pretty much anything. I am sure during his career he probably tried to clean his use up but would always fall of the wagon. In the song the rails represent a straight and clean way of living like normal society but going off the rails on a crazy train represents a drug induced state of mind.