I am going to the school which I loved.
(without a comma) is fully grammatical, and contains a restrictive relative clause - the "which I loved" is identifying which school is meant.
I am going to the school, which I loved.
(with the comma) is fully grammatical, and contains a non-restrictive (or 'commenting') relative clause: "which I loved" is an incidental fact about the school, not a way of defining which school is meant.
As you suggest, it is also ambiguous: it might be the school, or going to it, that the speaker loved.
I am going to the school I loved.
is equivalent to the first: the relative pronoun "which" may be omitted from a restrictive relative clause that it is not the subject of.
*I am going to the school, I loved.
is not grammatical: the relative pronoun cannot be omitted from a non-restrictive relative clause.
[There is a separate point that the tenses are a bit odd: "which I loved" implies that the speaker's experience of the school is in the past, but "I am going to" implies that it is in the present. There are special contexts in which this might make sense - for example, if I am going back to the school for a reunion. But without a special context, it reads strangely.]