I'm not sure about the actual circumstances of this because I sure as hell am not willing to read a thread that then refers me to another thread I'd have to read when you didn't actually point out what exactly the problem is. Like there has to be something between "girl broke up with me" and "history teacher gave me a worse grade". Exactly what was that whole thing about? What was your task for the grade and did you fulfill it?
About unfair treatment in school: Keep in mind that teachers have to grade you based on their perception, and as you might understand perception can never be objective. Teachers are asked to set an equal floor for every student and they are asked to not give any preferable treatment to individuals, but in reality a teacher is also only a human who can't make objective decisions. Run me through that process of why you think your grade was worse. What feedback did your teacher give you? Did you fulfill all tasks as well as any other pupil with a better grade? If you still feel unfairly treated after that you have a couple of options.
a) Talk to your teacher. Remember, he is just a human too and if anything he is the one who can tell you anything about why you were treated in a certain way. Maybe it clears up the situation a bit.
b) Talk to whatever contact persons your school has. Most have student representation of some form, most have teachers that are there to adress students' issues, or you could get in touch with the principal. Use these institutions, but don't overuse them. This is when you have actual evidence that you are being unfairly treated.
c) Suck it up. This might sound harsh but I've been a student for a long time and I've been working with students ever since I left school. Unfair treatment is alot of the time just misconceptions, misunderstandings or students misevaluating themselves or their work. Our psyche usually puts ourselves into the position of the victim automatically once something bad happens. That's nothing anyone gives you blame for, but be aware of that, that your own perception of things is usually blurred. I am only putting this option here since I don't actually know your situation. Don't take any offense in that, but odds are your unfair treatment wasn't actually as unfair as you saw it to be.
About unfair treatment in life generally: Life is not fair. Fairness is a construct and nothing can ultimately guarantee equality or fairness. This might sound a bit dystopian and all if you just put it that way so I want to point out that fairness is also an ideal that we as individuals and as society should strive for. That being said you should always keep in mind that fairness is only an ideal and ideals are not always reality. We all get born with certain features in certain environments, some people are privileged in certain aspects and some are not. You will find yourself in some form of unfair treatment or with unfair conditions in life eventually. All you can do is to find out why it is that way and try to improve the situation. Alot of life is about sucking up, alot of life is also about standing up. Try to get a good look on situations, try putting yourself in other people's shoes and then figure out when to do what.