A 404 page is a familiar way to indicate that someone is trying to access a non-existent page, but if you want to keep people on your site, there's a lot you can do to make your 404 page more useful.
Visitors come to your website looking for content; there are all sorts of reasons a visitor to your website might end up trying to access a page that does not exist. A typo or a bad link is all it take to lead visitors to a dead end, but you can create a 404 page that is far more useful than one that simply reads "this page does not exist". Smashing Magazine suggests that you build a page that tries to guess where visitors what visitors were trying to access, and suggest a number of possible pages.
You can do this using Google's Custom Search API to try to determine the intended destination using the current URL. Sign up for API keys from Google — you are limited to 100 API calls for day before you have to part with any money — and create a new search engine project on the Google Developers Console. Smashing Magazine has a code sample that can be used to create a custom search engine that automatically suggests a possible destination should a visitor hit a dead end.
Depending on how involved you want to get, you can take things further, and there are various examples in Donovan Hutchinson's article that show what is possible. Check out Donovan's own 404 page where you will see that a main suggestion is made, along with a series of secondary recommendations.
A Better 404 Page [Smashing Magazine]