In general in play they were ignored or just treated as an abstract language with no further comment.
As to where they came from, here's an answer from Gary Gygax on Dragonsfoot!
As D&D was being quantified and qualified by the publication of the supplemental rules booklets. I decided that Thieves' cant should not be the only secret language. Thus alignment languages come into play, the rational [sic] being they were akin to Hebrew for Jewish and Latin for Roman Catholic persons.
I have since regretted the addition, as the non-cleric user would have only a limited vocabulary, and little cound [sic] be conveyed or understoon [sic] by the use of an alignment language between non-clerical users.
If the DMs would have restricted the use of alignment languages--done mainly because I insisted on that as I should have--then the concept is vaible [sic]. In my view the secret societies of alignment would be pantheonic, known to the clerics of that belief system and special orders of laity only. The ordinary faithful would know only a few words, more or less for recognition.
In other words, it was supposed to be more like religious languages, but wasn't really well thought through. It disappeared in Second Edition and was not missed.
The solution is for the PCs to experiment with each of the spells to get a better feel for how useful they are during an actual game. Once your players have a chance to experiment a bit with the spells they have available to choose from, the task of deciding which ones are worth picking will be significantly easier. Also, as the DM, you may wish to reward good Intelligence or Wisdom checks made by the PCs during research activities by giving them suggestions as to which spells might prove useful over the course of the adventure. For example, if you're running the Lost Mine of Phandelver, you may wish to reward a player who spends time researching dragons that Green Dragons are masters of poison, so a Protection from Poison spell may be worth the Cleric's time to have prepared.
Because many of the 5th Edition mechanics and spell changes will likely be new for many players who did not participate in the playtest, the Adventurer's League Player's Guide also offers a nice solution to this problem. During levels 1-4 (the first major tier of gameplay) you can rebuild your character at the end of an episode or an adventure. This will allow you to try out low-level spell combinations without fear of being stuck with poor choices. Encourage low-level players to pick spells that sound cool and appear useful but not to fret over making bad choices because at the end of the session they can retcon their choices anyway.
It's worth mentioning that this should be significantly less of a problem for the Cleric, Druid, or Paladin because they each automatically have access to their entire class's spell list. If they wish to change the spells they have prepared, they can do so at the end of a long rest.
Lastly, note that some spells (those with the ritual tag) can be cast as rituals. This means the casting time is increased by 10 minutes (to prevent them from being used in combat), but the spell doesn't use up a spell slot. Bards can cast any ritual that they know. Clerics and Druids must prepare their rituals just like any other spell they plan to cast, but Wizards can use their spellbooks to avoid preparing rituals ahead of time. Warlocks who take Pact of the Tome have an invocation option which gives them the ability to learn every class's rituals in the same way as a Wizard. There is also a feat (Ritual Caster) which can grant ritual spellcasting to the other classes. This too will allow your players to try out more utility spells that may or may not be useful without making them sacrifice more pragmatic options like combat spells.
Best Answer
Each edition has different rules with respect to this. D&D 5e removed all restrictions and made alignment a general thing for characters. There is flavour text indicating which classes tend to do what, however the customization aspect allows for things like chaotic-evil Paladins.
For other editions, the easiest way to find out is to look up the class you're interested in and whatever edition you are playing.
For instance: Google search 3.5 Monk to find out that Monks need to be any lawful category.
As an example, D&D 3.5 has alignment rules for several classes such as Paladin, Barbarian and Druid.
Barbarians (any non-lawful); Paladins (lawful good); Druid (any neutral)