Detect Magic will enable the caster to see that there is a magical illusory effect on the Rakshasa (without actually being able to tell the creature is a Rakshasa)
The relevant portion of the Rakshasa's Limited Magic Immunity, for determining the answer to this question, is (emphasis mine):
The rakshasa can't be affected or detected by spells of 6th level or lower unless it wishes to be.
This is pretty clear, if Detect Magic affects or detects the Rakshasa then Limited Magic Immunity applies. So we have two follow up questions to answer:
- Does Detect Magic affect the Rakshasa?
- Does Detect Magic detect the Rakshasa?
Does Detect Magic affect the Rakshasa?
No, it does not.
Detect Magic alters the senses of the caster so they can sense and see magical effects. It does not alter the objects, spells or creatures from which magic might be sensed.
Does Detect Magic detect the Rakshasa?
The answer to this question is potentially more complicated.
Detect Magic has this text:
For the duration, you sense the presence of magic within 30 feet of you. If you sense magic in this way, you can use your action to see a faint aura around any visible creature or object in the area that bears magic, and you learn its school of magic, if any.
The spell can penetrate most barriers, but it is blocked by 1 foot of stone, 1 inch of common metal, a thin sheet of lead, or 3 feet of wood or dirt.
So the straightforward answer would seem to be No, Detect Magic, detects magic, not creatures.
But, you may ask, surely if you know there is an illusion on a creature then that illusion becomes see-through, no?
Why is this question important to ask? Let's pre-suppose the affirmative answer.
If disguise self does become see-through when it is discerned, then once the user uses their action to find out the class of the magic (illusion) the user would discern the disguise, and it would become see-through. This would be classified pretty clearly as a detection of the Rakshasa (as it's true form would be revealed).
In fact the answer to this follow up question is No the illusion does not become see-though once it is discerned.
An illusion becoming see-through upon detection is not a general rule for all illusion spells. Instead it is an effect that is applied to specific illusion spells by their text.
If we take the examples of Major Image and Minor Illusion, both have the relevant qualifier in their descriptions:
If a creature discerns the illusion for what it is, the illusion becomes faint to the creature.
The portion of Disguise Self that deals with discerning that a creature who is disguised is:
To discern that you are disguised, a creature can use its action to inspect your appearance and must succeed on an Intelligence (Investigation) check against your spell save DC.
Importantly discerning that a creature is disguised does not make the illusion disappear or become faint.
So...are we detecting the Rakshasa with Detect Magic?
No. We are detecting the effects of the Disguise Self spell, not the Rakshasa itself.
As a result the Rakshasa's Limited Magic immunity does not negate the Detect Magic spell from detecting the Disguise Self spell.
But surely detecting the illusion is "detecting" the creature?
No, it's not the same thing.
Lets pretend instead that we wanted to detect a magic weapon being held by the Rakshasa using Detect Magic. If we rule above that Detect Magic does not detect the Disguise Self spell, then we also have to rule that the magic weapon being held by the Rakshasa is not detected by Detect Magic.
But, if the Rakshasa drops the magic weapon while our Detect Magic is still running, then suddenly we would detect the magic weapon the moment it leaves the Rakshasa's hands. This oddity would then show that the Rakshasa is a creature with some sort of field surrounding it that limits detection, which then immediately gives a knowledgeable magic practitioner the ability to identify that the creature is a Rakshasa...thus detecting it!
Whereas if we rule that the Disguise Self can be detected, we learn nothing about the underlying creature. We also don't actually learn that the spell is Disguise Self, merely that there is an illusion spell overlaying the creature we can see. It could be any creature under the effect of an illusion spell (which may or may not be Disguise Self).
Are there examples of spells that would attempt to "detect" the Rakshasa?
There are two pretty common examples:
- Locate Creature. Locate Creature very specifically tries to locate a specific creature, and the Rakshasa can choose not to be detected by that spell.
- Alarm. Alarm needs to detect a creature entering the alarmed area in order for the alarm to be triggered. The Rakshasa can choose not to be detected by the Alarm spell.