Oceans are dirtier than pools.
Oceans are large bodies of water which can be contaminated by plastics, agricultural runoff, sewage etc.
Pools are often regularly treated and cleaned with chlorine which keeps them clean.
Bacteria can thrive in the oceans although the saltiness of the ocean can sterilize it someone.
Pools are also safer than oceans as oceans can pose some dangers such as jellyfish, sharks, other sea creatures and even waves and riptides that are unpredictable and can threaten even the strongest of swimmers.
The ocean is sanitary to swim in.
For example the vast majority of ocean waters such as along the coast of Los Angeles County meet State ocean water quality standards.
The only exceptions are areas that are adjacent to or in front of discharging storm drains and after major rainstorms.
Swimming in the ocean is significantly more challenging than swimming in a pool or most other places because you must contend with waves, the change of the tide, the slope of the beach, and strong currents that may be present even when the surface of the ocean appears calm.