In some cases, it can be helpful if instead of an error page, there should be a direct redirect to the home page. From an SEO point of view, this is not recommended, but the solution for this scenario is quite simple.
Solution: Create your own 404.php file in the theme folder and insert the following code. To be on the safe side, the original 404.php (if available) should be saved in case you want to use it later.
header("HTTP/1.1 301 Moved Permanently"); header("Location:".get_bloginfo('url')); exit();