This phrase means that when you were searching for something good for yourself, you received something even better that you weren't explicitly wishing for.
Example: Someone looking for a job gets their dream job instead.