It is a combination of the rules that are written for the effect the PC is saving against, and a DM call.
For example, the Fireball spell says
Each creature in a 20-foot-radius sphere centered on that point must
make a Dexterity saving throw. - PHB 241
So the spell that was cast defines what the saving throw is against. When it is a spell cast, the DC is determined by the caster's proficiency in the spellcasting ability for that spell.
For example, the Wizard class description says
Intelligence is your spellcasting ability for your wizard
spells, since you learn your spells through dedicated
study and memorization. You use your Intelligence
whenever a spell refers to your spellcasting ability.
In addition, you use your Intelligence modifier when
setting the saving throw DC for a wizard spell you cast
and when making an attack roll with one.
Spell save DC = 8 + your proficiency bonus + your Intelligence modifier
Spell attack modifier = your proficiency bonus + your intelligence modifier
Therefore, when a Wizard casts Fireball on a PC, the PC makes a dexterity saving throw, against the DC set by 8 + the wizard's Int + their proficiency bonus.
For other effects, there is also a theme to their saves. For example, saves against the poisoned effect are generally constitution saves (Stinking Cloud, Ray of Sickness, Poison Spray, etc.) and are described in their effects.
Anything that doesn't have a specific description (for example an improvised trap) would be decided upon by the GM, likely following the already common themes.
So a trap that emits a burst of flame would likely be a dexterity save, as you attempt to dodge the burst. A trap that emits a cloud of poison would likely cause a constitution save, as you attempt to withstand the effects of the poison. However, your DM might instead ask you to dodge the poison spray, so a dexterity save is called for.
Or do you add your highest ability modifier to the d20 rolled?
NO, however, sometimes it is the action that you (the player) describe your character (the PC) attempts to do that would guide the save. Again, it is up to the DM to decide how your description might work in game mechanics. If someone tries to push you over, you might choose to try and dodge them (dexterity) rather than resist them (strength). Of course, the DM can decide that you are in no position to dodge, and therefore fail a dodge attempt by default.