In those short sentences you give as examples, they can be interchangeable for normal, everyday use. That they are interchangeable here could be due to insufficient context around the sentences. Can versus could is more subtle than may versus might, or can versus may. Could is more subjunctive, tentative, but can is more firm - at least in this context.
Note that "What for?" is informal/conversational.
"What Purposeful Reason?"
"What for" denotes a purposeful reason, while "Why?" can be used for causes, reasons, or explanations.
- Statement 1: "I am going to work now."
- Why? (Explanation): "Because it's time for me to leave."
Why? OR What for? (Purpose): "To make money."
Statement 2: "Things fall."
- Why (explanation): "Because of gravity..."
- Why (Purpose): "Because of gravity." / "No, I mean, why is it like that? Why is there gravity?" / "Who knows? That's just the way it is. God? Quantum Multiverse? That may not be answerable."
What for (purpose only!): "Who knows? God? Quantum Multiverse? That may not be answerable."
Statement 3: "I exist."
- Why (Explanation/Cause): "Because your parents had sex, your mother got pregnant, and you were born."
- Why OR What for? (Purpose): "In order to propagate the species." OR "For God's mysterious reason." OR "Nobody knows." OR "There is no purpose; it's a quantum multiverse."
Variations can be created by sentences like "What is $NounPhrase$ for?" For example, if one is in a new car with a salesman, one can ask "What is that button for?" In this case, the question is asking for the functional purpose of the button. Also, "What is math good for?" is asking for suitability for a purpose.
"What for!?" -- Emphasis / Surprise / Suspicion
"What for" can lend itself to more emotion than a simple "Why", adding surprise, suspicion, or just more emphasis. In this case, "what for" can be asking for an explanation just like "why":
- Statement 4: "I am going to work now."
- What for!? You just got home! (Surprise/Explanation): / "Because I left my wallet there."
The emotion behind "What for?" can also be suspicion or interrogation. There can be a bit of eye squinting or head tilting:
"Can I ask you your name?"
"Ummm. What for?" (Suspicion)
"For what?" -- Identifying ambiguity.
"What for" can also be used to mean "For what?" in order to identify an ambiguous reference. The emphasis is on replacing the "what" with the named item rather than replacing the "for" with the named reason:
- "I'm looking for something." / "For what?" / "For my glasses."
- "I'm looking for something." / "What for?" / "My glasses." (Same as "For what")
- "What are you looking for?" / "My glasses."
Here's another one:
- "I need some help." / "What for?" / "To reach that top shelf." / "Ok, what for?" / "That coffee mug."
Both "what for" questions could be asking for purposeful reason. For example, in the 2nd case, the reason could have been to clean the shelf. But the answer given in the 2nd case was an identification of the object desired.
Also, "What am I responsible for?" is asking for identification of responsibilities. It is like "For what am I responsible?", but the fronted what sounds more natural.
Best Answer
Nearly can almost always be replaced with almost. However, there is a rare use of nearly to mean closely (ODO gives the example "more nearly related", meaning "more closely related" - here "almost" wouldn't work).
In its other, more common usage, nearly has the same meaning as almost, although perhaps almost is slightly stronger. (ODO, the full OED and Collins all define "almost" as "very nearly" - although all three also define "nearly" as "almost".)
Most of the time when we say almost, we could just as well say nearly. However, almost also has a use that nearly doesn't.
Even though ODO only gives one definition for almost, the word nearly would work as a substitute in some of the examples it gives and not in others.
For example, either word could be used in these sentences:
But almost is the only possibility in the following examples:
In the sentences above, almost doesn't mean "nearly". It means something more like "more or less".
Cambridge explains that:
To my ear, I don't think "nearly any" sounds unacceptable, but "nearly no" and "nearly never" are distinctly unidiomatic.