It is an exclamation used when you are happy that something difficult or dangerous has finished or is not going to happen, or when you are tired or hot.
Phew! it is really hot in here. Phew! I am glad I don't teach that class very often, they are monsters.