When you write a roman numeral, there are small numbers on the top right, what do they mean?

The numbers are called figured bass, and refer to the interval above the note. So for instance, in a I chord, you normally don’t write the numbers, because it is assumed that a roman numeral by itself is in root position. If you were to write the numbers they would be 5 on top and then 3 on bottom.

You can see here, the interval between the C and the E, is a 3rd. The interval between the C and the G is a 5th.

If we move to the 1st inversion, the interval from E to G is a 3rd, the interval from E to C is a 6th.

Finally the 2nd inversion, the interval from G to C is a 4th, and the interval from G to E is a 6th.

This means that you can also have different roman numerals but the same intervals. So a G 6/4 chord, can be a I6/4, or a V6/4 depending on it’s function. A V6/4 is actually a dominant embellishment. A I6/4 chord is a tonic chord.