In short, because of early introduction of effective, compulsary education in reading and writing for children.
In 1640, the Swedish parliament mandated that each city should found a school for children to learn reading, writing and mathematics. The Church Law of 1686 compelled pastors to educate children in reading and bible studies - a task that was customarily passed on to the bellringer. A 1723 law also compelled parents to teach their children to read, without further specifying how except, again, that they should be able to comprehend certain bible verses and other Christian texts. This era was characterized by "husförhör", or the practice of pastors verifying literacy through testing their flock on the Lutheran Catechism, and reporting the results nationwide.
In 1762 a vague and rarely followed ruled provided for schoolteachers taking the place of the bellringer, and by 1840 there were more than 1000 permanent schools in the country, with ambulating teachers in the countryside. Parliamentary discussions on how to proceed with the education of the poor and rural resulted in the introduction, in 1842, of compulsary primary education for all - "Folkskolesystemet". Similar laws weren't passed until 1870 in the UK (where it wasn't followed until 1880 because of widespread child labour), and 1881-1882 in France (the Jules Ferry laws).
Incidentally, Frederick the Great implemented a similar system (the "Generallandschulreglement") in Prussia as early as 1783. Other German states followed suit, and in the mid-1800s literacy rates were generally over 80%, with Prussia at 85%.
Sources: