What happens if a commercial airplanes navigation system completely failed during a flight?
The possible answers to your question are for all practical purposes infinite depending on the details of the system failure, the weather, where you are, and crew experience, to name a few. However, as a thought exercise extremely unlikely to ever happen in reality, let's play with it a bit.

First, let's define the navigational systems failure to be such that we cannot determine our position by reference to instruments in the cockpit. What have we got left? If we can still communicate, others can work with us to determine our position and develop a course of action.

The simplest case would be if we were talking to ATC, were in an area of secondary radar coverage, and our transponder was still working. If that were the case, it would be a matter of getting radar vectors to wherever we wanted to go. If I were the captain, I would want to go to the nearest suitable airport since if I had had a failure of everything that could tell me in-cockpit where I was, I would be worried about possible further failures.

If talking to ATC and in an area of primary radar coverage only or you also had transponder failure, they could give us a series of turns to identify us (used to do that back in the 1960s occasionally).

If you were out of range of VHF communications with ATC, you could try getting a relay via another aircraft that was in VHF range of ATC. Two aircraft at altitude can talk to each other at far greater distances than an aircraft to a ground station. A simple call to any listening station or aircraft on 121.5 requesting assistance will almost always get a response.

If VHF communication is not possible, you could try getting a patch through to ATC on HF radio. My favorite back in the 1990s was Stockholm radio. These days, however, SATCOM is available. I don't know anything about it, but I imagine it provides the ability of an aircraft anyplace in the world to be patched through to an appropriate ATC facility.

So, if you're talking to ATC (by whatever means) but you're out of radar coverage, what then? Every captain would remember generally where he was prior to the failure. It could be as simple as someplace in the North Atlantic and eastbound. He could simply tell ATC that and that he will fly a westerly heading. ATC would clear the altitude he was at and look for him along the westerly limits of their radar coverage for when he inevitably would show up. Actually if it was the North Atlantic and it was nighttime, he could just follow any airplane in front of him. They're easy to see stacked out into the distance.

The general idea would be to get to where you could be seen by ATC, and go from there. Anymore, there aren't a lot of areas along regularly traveled airline routes over land in North America and Europe where above 30,000 ft an airline flight won't be seen. That was true back in the 1990s, more true now I am sure, and increasingly true through the world, especially if military radar can be utilized..

The more interesting problem becomes that there is a loss of communication as well as a loss of navigational ability. The possibilities here are limitless. A simplification would be to say that what you would do would be to take up a heading that you believe will get you to where you could visibly see a land mass with airports, and land at the first suitable airport you see. Most airline flights are along routes that the crew is very familiar with; they know what they've been flying over many times, and that would be a help.