Why is it that a scriptable objects can not hold a reference to a script file?

Say we have created the following scripts:

public class BaseSpell : Monobehaviour
{
 public virtual void Activate() { }
}

public class Fireball: BaseSpell 
{
 public override void Activate() { // Shoots fireball }
}

Why is it, that in unity you can not directly refer to these scripts within scriptable objects?

For instance, if I wished to create a scriptable object for an item, that unlocks a certain spell, the following would compile but would not allow to be allocated within the inspector:

public class MyScriptableItem : ScriptableObject
{
 public Basespell spell; // The reference of the spell that I wish to activate
}

Now I am able to work around this, but I wish to understand is there any specific reason, like a bad practice why this is not allowed?

A ScriptableOBject can reference a runtime script. However you can not have the scriptable object be serialized. When you have a ScriptableObject stored as an asset, it actually lives in the project. MonoBehaviour instances live inside a scene. Objects in a scene only exist when they are loaded. So something that is persistent like a ScriptableObject asset can’t reference something that may or may not be there.

A ScriptableObject asset can actually reference MonoBehaviour components on a prefab as prefabs are also assets. However that would still not reference the instance in the scene but only the prefab instance itself.

ScriptableObjects can also reference instances in the scene, but only when they are assigned at runtime and such an assignment would only last for the time the game is running and the scene is loaded.

It’s not clear what you want to do exactly.