So to complete a bit some other answers like Deep Terror Nami.
There is two key parts in the grading system:
- They choose a series of metrics to evaluate your performances.
- They compare your score with those metrics to the score of other people playing the same Champion/Role combination. Your grade correspond to the % of players that did better than you.
To elaborate a bit on the first point: Riot always refused to say what metrics exactly, but people have tried to guess. It's pretty sure that it contains at least CS, number of deaths, number of kills; and Riot also confirmed that for Supports specifically kills+assists counts as a single score (which implies that for non-Supports, assists either count less than kills or even not at all).
Beyond that, no one really knows for sure, but common hypothesis include: kill participation, wards placed and destroyed, damage dealt and taken (either in absolute or in percentage of the team), number of towers takedowns, number of Dragons/Barons your team got (for the Jungler position), and all metrics may or may not be normalized by game length. There is also the fact that all factors don't count as much as each other, and the exact weight of each factor can vary position by position.
I understand that Riot wants to minimize players gaming the system, so they don't want to say exactly how it functions, but I always argued they should at least reveal the list of metrics used, if not the exact weights.