Why we are using client.flush() in the program code ,when we connect Esp8266 with internet or web server?
This is most likely related to the old usage of .flush() from pre IDE version 1.0.0.
In those old versions .flush() would erase any pending data in the reception buffer. It was the equivalent of:
while (client.available()) {
    client.read();
}

Now though it's used to ensure that all data has been sent before doing anything else. In this situation it's completely meaningless.