Y is an indirect object pronoun that is used to replace 'à + noun' if the noun is not a person (if the noun is a person, you should use lui or leur).

y
=
à
+

thing
place
idea
animal

(expressed as a noun)


Places

Y is often used with places (in English we would say 'there').

Je viens directement de la gare. J'y ai laissé mes bagages.
                                                (= J'ai laissé mes bagages à la gare.)
(I've come directly from the station. I left all my luggage there.)

J'aime beaucoup la Nouvelle-Orléans. J'y vais très souvent.
                                                (= Je vais à la Nouvelle-Orleans très souvent.)
(I like New Orleans a lot. I go there very often.)


Nouns in general

Y is used to replace masculine and feminine, singular and plural nouns.

Est-ce que tu as une réponse à ma question ? Non, j'y pense toujours.
                                                (= Je pense toujours à ta question.)
(Do you have an answer to my question? No, I'm still thinking about it.)


Other prepositions

Y can also replace 'dans + noun' if the noun is not a person.

J'écris un journal depuis trois mois. J'y note toutes mes pensées.
                                                (= Je note toutes mes pensées dans mon journal.)
(I've been writing a diary for three months. I record all my thoughts in it.)

But it is most commonly used with any verb that typically takes à with a noun (where the noun is not a person), such as penser à (to think about/of), répondre à (to reply to), réussir à (to succeed in)...

J'ai un examen dur la semaine prochaine, et je veux y réussir.
                                                 (= Je veux réussir à mon examen.)
(I have a difficult exam next week, and I want to pass it. (...succeed in it.)
J'ai reçu votre lettre, mais je n'y ai pas encore répondu.
                                                 (=Je n'ai pas encore répondu à votre lettre.)
(I have received your letter, but I haven't yet replied to it.)


A final note...

Y is often used with aller.

Tu vas au cinéma ce soir ? Oui, j'y vais.
Are you going to the movies this evening. Yes I'm going (there).

In fact, aller is a verb that always has to be followed by something. You always have to include some noun or pronoun to indicate where you are going. This means that when you don't want to bother repeating where you are going, you have to include at least the pronoun y, as in the example above. Whereas in English we can say 'I'm going', in French you have to say 'J'y vais.'

This means that there are certain fixed expressions with aller that always include an y (unlike their English equivalents).

On y va ? Shall we go?
Oui, on y va ! Let's go!
Vas-y ! Go on!
Allons-y ! Let's go!
Allez-y ! Go on!
J'y vais ! I'm going!