means that
it can be prudent to maintain workable relations with powerful people on whom one's safety or livelihood depends.
The saying “If you have to live in the river, it is best to be friends with the crocodile” can be used when it is wise to be in good terms with the most powerful persons in your environment.