In Selenium web driver, the biggest challenge is to synchronize your script with the Web application under test. To make this synchronization work, we have concept of waits. Although we can use Thread.sleep() which pauses your script for the specified milliseconds but it is not recommended to use as whether your requirement is fulfilled or not, it is definitely going to pause your script for the specified time.
Instead if we use waits we give a maximum timeout. For example, if we have given a maximum timeout of 20 seconds and our requirement gets fulfilled in just 2 seconds so remaining 18 seconds will be saved and it will continue with the next line of code.
Mainly we have these types of waits:
1. Implicit wait
2. Explicit wait
3. Page load timeout
So it's always recommended to use waits instead of Thread.sleep() if your requirement is to wait for some web element to be visible, cllickable, element present or not, and so on.