Making it very simple here.
First look at this picture. The columns are a range for rating difference and then two percentages (one for the higher rated player "H" and one for the lower rated player "L").
For example, the first entry is 000-003 50 50 . This is saying for players who have a rating difference of zero to 3, they're each expected to score 50%

Turn the % into a decimal. So 61 becomes .61 or 32 becomes .32 and so forth.
Results are win loss or draw. Results count as 1, .5 or 0.
After a game your rating is adjusted by subtracting the decimal from your result and then multiplying by 20 (making it as simple as possible here, the number 20 isn't always used).
So lets say you play someone rated 200 points below you and win. We want the result - the decimal. Using the chart, the decimal for the higher rated player is .76 and you scored a 1 because you won.
1- 0.76 = 0.24 and that multiplied by 20 is 4.8, so you gain almost 5 rating points.
Another example. You play someone rated 100 points above you and draw. .5 - .36 = .14 and x20 = 2.8
----------------
This is a simplified version of Elo formula. Without a chart the math is more complicated, and as I said above, x20 isn't always used.
On chess.com they use Glicko instead of Elo which gives and takes away more points for new and inactive players and less points for people who have played a lot recently. The logic is the more you've recently played, the more accurate your rating is. And if you haven't played in a long time, your rating may not be correct (you may have gotten better with study or worse with inactivity).
So playing here, in your games you may notice you gain/lose even 100 or 200 points at first. Then the more you play, you get to gaining and losing more like 5 per game.
How do the rating system work?