Gratis (Spanish for “free,” in the sense of “free beer”, not “free speech”) is a close cousin of the English gratify and gratuitous (and its cousin gratuity).
Upon realizing this, it suddenly becomes obvious: all share the gr-t root, plus vaguely related meanings. All come from the Latin gratus, meaning, “pleasing.”
Its parallel becomes more obvious when we think of the connection of the English words to the original meaning of “pleasing”: that which is gratifying is pleasing, and you leave a gratuity when you are pleased. And gratis, free, is a reward to those who want to please others!