First you must understand that classes are instances too -- instances of the Class class.
Once you understand that, you can understand that a class can have instance variables associated with it just as a regular (read: non-class) object can.
Hello = Class.new
# setting an instance variable on the Hello class
Hello.instance_variable_set(:@var, "good morning!")
# getting an instance variable on the Hello class
Hello.instance_variable_get(:@var) #=> "good morning!"
Note that an instance variable on Hello is completely unrelated to and distinct from an instance variable on an instance of Hello
hello = Hello.new
# setting an instance variable on an instance of Hello
hello.instance_variable_set(:@var, :"bad evening!")
# getting an instance variable on an instance of Hello
hello.instance_variable_get(:@var) #=> "bad evening!")
# see that it's distinct from @var on Hello
Hello.instance_variable_get(:@var) #=> "good morning!"
A class variable on the other hand is a kind of combination of the above two, as it accessible on Hello itself and its instances, as well as on subclasses of Hello and their instances: