은 (eun) is always used after a word (a noun, a noun phrase, or a nominalized verb/adjective in ㅁ (m) form), ending in a consonant. Identical in meaning to 는 (neun) which is only used after a word ending in a vowel.
(topic marker): The topic is what is being talked about in the sentence, it is the main point. This however is different in meaning from the subject which the predicate directly refers to. The topic and subject may be the same in a sentence. For example,
매리는 내 친구다.
Maerineun nae chin-guda.
Mary is my friend.
In this case "Mary" is the topic (and the subject) of this sentence and "is my friend" is the predicate. However, in many cases, the subject and topic are different.
이 반은 학생이 똑똑하다
i baneun haksaeng-i ttokttokhada
Speaking of this class, the students are smart.
Above, the topic is "this class" while the subject is "the students".
In cases like this, the topic can often be thought of as a range, or to what extent the sentence is applicable. In the example above, if "speaking of this class" was removed, the sentence would not be limited to "this class", and would talk about all students in general.
(contrast/emphasis marker):은 (eun), can be placed after most case markers (including 가 (ga), 를 (reul), 에 (e), 에게 (ege), 에서 (eseo), 로 (ro), 과 (gwa)) to show contrast between two or more choices or add emphasis to a word or phrase, depending on the context. If used after 가 (ga) or 를 (reul), the 가 (ga) or 를 (reul) are deleted leaving only 은 (eun).
나는 서울에 가고 싶다.
Naneun seoure gago sipda.
I want to go to Seoul.
나는 서울에는 가고 싶다.
Naneun seoureneun gago sipda.
I want to go to Seoul (and not Busan). / I want to (especially) go to Seoul.
나는 존에게 책을 주었다.
Naneun jonege chaegeul jueotda.
I gave John a book.
나는 존에게는 책을 주었다.
Naneun jonegeneun chaegeul jueotda.
I gave John (and not Fred) a book. / I gave (especially) John a book.
In cases where there are two cases of either 는 (neun) or 은 (eun) in a sentence it is assumed that the first usage refers to the topic while the second usage refers to some contrast or emphasis.