This Exception occurs when driver is trying to perform action on the element which is no longer exists or not valid.
WebElement ele = driver.findElement(By.id("sample"));
// Before clicking some thing happened and DOM has changed due to page refresh, or element is removed and re-added
Now at this point, the element which you're clicking is no longer valid.
so it throws up its hands and gives control to user, who as the test/app author should know exactly what may or may not happen.