It's often used to console someone who is heartbroken or feeling rejected. It suggests that just because one relationship didn't work out, it doesn't mean that there aren't other people out there who would be a good fit.
Here are some examples of how it might be used:
* "I know you're hurting right now, but remember, there are plenty of fish in the sea."
* "Don't get discouraged if this job doesn't work out. There are plenty of fish in the sea."
The expression is often used in a lighthearted way, implying that finding the right person or opportunity is simply a matter of looking around.