The function you wrote says, "Give me something, and I will give it back to you." The type you wrote says, "I can convert an Int into any type you the caller would like, as long as that type is an instance of the IntClass typeclass."
When we put those together, we have a function that will take an Int from the caller, and give it straight back. Except that when that very same Int is returned, it will be a value of any type the caller would like as long as that type is a member of the IntClass typeclass. How can the input go from being an Int to any (constrained) type the caller would like? It can't. Since the input is given straight back, the return type must be the same as the argument type. The type checker infers this from your code, but then can't reconcile that inference with you naming the output type r. The type checker wants to work with you on this, but can't be sure that r is the same thing as Int given the sole hypothesis that r is an instance of the IntClass typeclass.
A function rather like the one you wrote is fromInteger, found in the Num typeclass. If you want to talk about all types that you can construct based on an Int, then this should be a method of your typeclass. Something like:
class IntClass a where
intToIntClass :: Int -> a
You would define this method for every type that you want to be an instance of IntClass, and would have your desired type of intToIntClass :: IntClass r => Int -> r. This return type polymorphism depends critically on each participating type having an appropriate definition of intToIntClass.
(r ~ Int)part of the top line in the error message means "Could not deduce type r is the same type as Int".~(tilde) means type equality which once you are used to it is fine, but if this is the first time you've seen it then it's a bit bizarre. Using the more natural=for type equality would make Haskell's syntax ambiguous when it is used in programs rather than error messages.