This page of the guide to Ratchet & Clank Rift Apart explains whether you can swim in the game. Additionally, you will learn of how to cross large bodies of water and whether you can dive.
The game protagonists theoretically can swim, but in most situations it is very dangerous or even impossible. Moving around is completely safe only in shallow reservoirs (e.g. ankle-deep ones), where the character will simply run instead of swimming.
In deeper waters, jumping into the water can mean that the character will automatically drown (e.g. on planet Sargasso) or be quickly eaten by carnivorous fish. Interestingly, drowning or being eaten alive does not mean you have to restart from the last checkpoint. You will simply be brought back to shore.
In some deep waters, you can find e.g. small islands, interactive hooks you can grab and swing from, or rafts that you can bounce on. This help you get through a particular location.
The game will allow you to swim freely in several places - the place in the picture above is related to the planet Ardolis, visited later in the campaign.
A big plus is that on planets with lots of water (e.g. Sargasso) there's a chance to find Speetles - these creatures can move through the water very quickly. Using Speetles is the best way to travel between locations separated by vast bodies of water.
When using a Speetle, keep in mind that after jumping off the friendly creature, you won't necessarily find another Speetle right away. Before you end a ride, try to make sure you will be able to easily return to the main locations or find a Speetle nest.
You can't dive everywhere you want. However, it should be noted that on one of the planets later in the game, you can roam around the bottom of the sea for a short period of time. Then, very similar rules apply to using magnetic tracks - the character is "glued" to the bottom and can jump between adjacent tracks only to a limited extent.
As you explore the depths, you will have to eliminate monsters, and you can also find some secrets, among other things. However, there is no limit to how long a character can stay underwater. You can freely return to the underwater area.