A hymn is a formal song of praise addressed to God, written in stanzas and in meter, and meant for a whole congregation to sing rather than for a soloist to perform. That last part matters more than it sounds. A hymn has to be singable by people who did not choose it and have not rehearsed it, and that constraint shapes everything about how one is written.
The word comes from the Greek hymnos, a song of praise. The Greeks sang them to their gods and to their heroes. Christians kept the form and changed the address.