Hey Karan, we create a reference variable to webdriver type because we could use the same Webdriver variable to hold the object of any browser such as the ChromeDriver, IEDriver, or SafariDriver, etc. We follow this approach as it can work with any browser instance.
WebDriver driver = new FirefoxDriver();
WebDriver driver = new ChromeDriver()
The following method is also correct but it will work only with the Firefox.
FirefoxDriver driver = new FirefoxDriver();