Bottom line: the real reason is because it sounds better to the native ear. Most linguists dislike this kind of explanation, because it has no neat, ‘rational’ basis—i.e., it doesn’t fit into a neat, predictable category—and yet it ultimately explains most, if not all, exceptions to neat rules in all languages. Thus:
- the word lailah לילה, is masculine (despite the -ah ending, which is typically feminine) because lailah tovah (‘good night’) sounds awkward.*
- Conversely, derekh דרך is feminine, because it sounds better with feminine adjectives.
- Some words—such as shemesh שמש (sun), gerev גרב (sock), and sakin סכין(knife) are officially considered as both (or either) masculine or feminine.
- Some—such as panim פנים (face), sadeh שדה (field), and kos כוס (glass/cup) were one gender in the Hebrew Bible, another in the Talmud, and one or the other in modern times.
- And some—like tzomet צומת (junction)—have the distinction of being regarded as feminine in singular, and masculine in plural (you can test this yourself: grab a native Israeli, and ask them how do they say “at the next junction” and “at the next junctions” in Hebrew. Nine times out of ten (unless they’re a Hebrew linguist), they’ll say batzomet haba’ah (fem.), but batzmatim habaim (masc.) in plural.
If you need a broad rule of thumb, sound out a word with masculine and feminine adjectives, and see which sounds better. Chances are you’ll get it right—even if you’re only starting out in the language.
*A similar thing occurs in Spanish: día and agua are masculine (probably because un día sounds better than una día, and la agua is awkward, but el agua is not), but foto is feminine. So, as you can see, the ‘sounds better’ rule is possibly universal.