The first test carried out in a normal melee or ranged attack is for a miss. (A target that is not standing is automatically critically hit. “Normal melee or ranged attack” means the target is standing.)
The difference between the attacker’s Attack Rating and the defender’s Defense determines the chance to miss a melee or ranged attack. When a player or mob attacks a player, the chance is a base 5% plus 0.04% per rating difference. Level is not a factor except when attacking a mob level 9 or lower. Miss chance against a low-level mob is a percentage of normal equal to the mob’s level divided by 10. When a player or other mob attacks a mob, the change in miss chance is 0.2% per rating difference if that rating difference is 11 or more. If the rating difference is 10 or less then the change in miss chance is 0.1% per point. If the attacker and defender have the same ratings then of course the total miss chance will be 5%.
Dual-wielding is a special case. The chance to miss on each weapon is 80% times the chance calculated above, plus 20%. If a miss chance calculated as above comes out to 5% then dual-wielding increases this miss chance to 24% (which is 80% * 5% + 20%) for each weapon. A 10% miss chance with one weapon would become a 28% chance for each dual-wielded weapon, and so on.