Updated:

1. Trident for throwing

/give @p trident[enchantments={loyalty:3,channeling:1,impaling:5,unbreaking:3,mending:1}] 1

Loyalty brings the trident back after a throw. Channeling calls lightning on the target during a thunderstorm. On 1.20.5 to 1.21.4, write enchantments={levels:{loyalty:3,...}} (NBT vs components).

2. Trident for travel

/give @p trident[enchantments={riptide:3,impaling:5,unbreaking:3,mending:1}] 1

Riptide launches you forward when you throw in water or rain. A Riptide trident cannot be thrown as a weapon, so keep it separate.

3. Trident enchantments

IDMaxEffect
loyaltyIIIReturns after a throw
riptideIIILaunches you in water or rain
channelingILightning on hit during thunder
impalingVMore damage to aquatic mobs (Java)
unbreakingIIILasts longer
mendingIRepairs with XP

On Bedrock, Impaling boosts damage against any mob in water or rain.

4. Use it with lightning

/weather thunder 600

Channeling only works in a thunderstorm and on targets under open sky. See the weather command and the lightning command.

5. Over-max levels

/give @p trident[enchantments={loyalty:3,impaling:255},unbreakable={}] 1

Very high Riptide levels throw you so far that fall damage gets likely, so start at 3. See the enchantment ID list.

Bedrock Edition

/give @p trident
/enchant @p loyalty 3
/enchant @p channeling 1
/enchant @p impaling 5

Hold the trident while running /enchant. Bedrock stops at the normal max levels.

Troubleshooting

Check your command

The Command Error Doctor checks common syntax mistakes in your browser.