If you will be studying in Sweden for more than three months and you are not an EU citizen, you need a residence permit.
If you will be studying for less than three months, you may need a visa instead.
List of countries whose citizens need a visa
The quickest and easiest way of applying for a residence permit to study at universities and colleges in Sweden is to apply online.
Online application on the Swedish Migration Agency website
You can find out which rules apply, which documents are required and how you apply, from Migration Agency's website.
If you are interested in studying at university/college/master's level in Sweden, you can find a full range of information on the Study in Sweden website.
Study in Sweden - in brief