I will tell you step by step as how to do this, please follow the steps and you are good to go.
1. set the path of your chrome/ firefox driver you are going to use.
System.setProperty("webdriver.chrome.driver","C:\\Your\\Path\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
2. Open the youtube webpage
driver.get("https://www.youtube.com");
3. Get the id for the search box and type the keyword.
driver.findElement(By.id("search")).sendKeys("Happiness");
4. Click on the search key.
driver.findElement(By.id("search-icon-legacy")).click();
Hope this helps!