Firstly, unless you are at a competition - sparring is not a competition, or a fight
Unless you are some sort of martial arts god - you are going to get hit
I can't count the number of students who seem to forget these two crucial points.
You can learn and improve from every spar, even if in an actual fight it would be one-sided.
Pick 1 at most 2 things to work on, I usually pick some techniques that we did in the class prior to sparring as that is fresh in my mind, and repeat repeat repeat until it works for you.
I frequently have smaller, lower grade students land shots on me - that's a good thing - they have shown me what I am doing wrong in whatever I was practicing.
As to the benefits of fighting a higher grade opponent - well, its a bigger learning curve for sure, but they will show you gaps in your guard that the lesser experienced may not have been able to hit. They will show you movement that the lesser experienced may not know or be able to pull of smoothly. They will show you how to effectively use techniques that the lesser experienced may not. They will show you how the attacks you throw can be blocked, evaded, negated or countered. Generally, the better the quality of opposition you face the better you will become - You just need to accept that each spar against an opponent like that will be a lesson.