In the MM it states that the rakshasa is immune to magic of 6th level or lower. Does this include the counterspell spell or does counterspell target the spell and not the creature?
Counterspell says that:
You attempt to interrupt a creature in the process of casting a spell. If the creature is casting a spell of 3rd level or lower, its spell fails and has no effect. If it is casting a spell of 4th level or higher, make an ability check using your spellcasting ability. The DC equals 10 + the spell's level. On a success, the creature's spell fails and has no effect.
We can contrast this to Dispel Magic, which specifically allows you to target
one creature, object, or magical effect within range.
While Counterspell doesn't explicitly state that you are casting it on the creature rather than the spell itself, phrasing like "a creature in the process of casting a spell" rather than "a spell being cast" and "If the creature is casting a spell of 3rd level or lower" rather than "if the spell being cast is 3rd level or lower" suggests to me that Counterspell does indeed target the creature rather than the spell itself.
That being the case, the rakshasa would be immune to Counterspell unless it was cast out of a 7th level or higher spell slot.
I would like to offer a different point of view from the one presented by Miniman and backed by the official Sage Advice Compendium (link in the comments):
The spell Counterspell does not specify a target but both its name and effect seem to refer to a spell rather than a caster. As such, it is the spell that suffers the effects of Counterspell, namely the failure to being cast. As a consequence, the caster is not able to successfully complete the casting of the spell but they themselves are unaffected. As such, while the Rakshasa is immune to magic of 6th level or lower, the magic he produces is not.
Therefore, I would argue that a spell cast by a Rakshasa can be counterspelled much in the same way that an illusion cast by a Rakshasa could be dispelled.
Based on an unofficial response from Jeremy Crawford on Twitter (regarding whether Counterspell affects spells from magical items), I would say that it is the creature that is targeted and not the spell. His words were:
Counterspell targets a creature casting a spell, no matter the source of the spell (the creature, an item, etc.).