The numbering is that way because it was the tactic that was mostly (as in 95% of the teams) used when the numbering system was created.
Tactic:
11 10 9 8 7
6 5
4
3 2
1
The numbers were attributed from back to front, from right to left.
1- Goalkeeper
2 - Right Defender
3 - Left Defender
4 - Anchor Man
5 - Right Midfielder
6 - Left Midfielder
7 - Right Winger
8 - Right Interior
9 - Centre Forward
10 - Left Interior
11 - Left Winger
With the evolution of tactics the 4, 5 or 6 numbers started to be used by defenders as the teams started playing with 3 and then 4 defenders. the left back and right back were pushed to the lines, and that's why there's usually a 4, 5 or 6 as central defender. Most countries adopted the 4 and 5 as CB and 6 as midfielder, but some started using the 5 and 6 as centre backs as the anchor man was still used in some countries so they left him with the "4".
The forward line remained more less the same, just with the wingers needing to go back a little so they kept the same numbers. The 8, 9, 10 change a lot because of different tactics adopted by different countries and teams stopped playing all alike. As a lot of great football players happened to play in the Left Interior position the "10" started to be used in most of the world as the "star" number, which usually matches the flair-based playmakers. The 8 was the remaining offensive position so depending on the tactic of the team he could be the second centre forward or a centre midfielder.
Nowadays, this doesn't matter much at all as a lot of players pick the numbers they like without caring much about this. Still, you can usually see the pattern, only with slight changes.
Also, there's no obligation of a player playing with the number 1 being a goalkeeper. Argentinian Ossie Ardiles won a world cup playing with the 1 on his back from the midfield. It wasn't the only outfield player who wore a 1, but the only one to won the cup. He used it because it defined the organizer, the one player the team played around, according to an interview i read from Argentina's Manager at the time.