How to benefit from living with difficult people and undesirable circumstances?

How to benefit from living with difficult people and undesirable circumstances?