The FIFA ranking procedure is detailed here
The basic logic of these calculations is simple: any team that does
well in world football wins points which enable it to climb the world
Each team points are calculated in a four-year period.
Calculation of points for a single match is calculated in the following formula:
P = M x I x T x C
When the following factors taking into consideration:
- M - Match result, Teams gain 3 points for a victory, 1 point for a draw and 0 points for a defeat. In a penalty shoot-out, the winning team gains 2 points and the losing team gains 1 point.
- I - Match importance, Friendly match equal 1 point, FIFA World Cup™ qualifier or confederation-level qualifier worth 2.5 points, Confederation-level final competition or FIFA Confederations Cup equal 3 points and the biggest world tournament FIFA World Cup™ final worth 4 points.
T - Opponent strength, calculated by the following formula - , when the minimum multiplier is 0.5 for team ranking 150th and under. The ranking position is taken from the the most recently published FIFA World Ranking.
C - Confederation strength, In addition to the opponent strength, it also considers the relative strength of entire confederations, UEFA/CONMEBOL = 1.00, CONCACAF = 0.88, AFC/CAF = 0.86 and OFC = 0.85. When calculating matches between teams from different confederations the mean value of the confederations is considers into account.
each match point is also multiple by the match date:
Match average from past 12 months is multiply by 1,
Match average from previous year is multiply by 0.5,
Match average from year 3 is multiply by 0.3,
Match average from year 4 is multiply by 0.2,
Matches older than 4 years is multiply by 0 and deleted.
All national team points are summed up to the magic number which is the national team ranking
another source is Wikipedia