The first number indicate the minimum width of the field, for example "%2d" will print a number at least two characters wide. If the actual number is only one digit the first character will be a space. If the actual number is more than 2 digits the program will display however many digits are needed to format the number.
>>What does putting the numbers in front do, since it works the same without them
No it does not. Replace the value of i with the number 1 and see how different it is when you replace i with a number such as 12345.