Is there a difference or a grammatical mistake in this two sentences?
- All the questions needn't be answered
- All the questions are not needed to be answered
This is a pretty good example of how you can't just expand contractions to make your writing "more formal"; you often must also shuffle the words around and change verb forms or even verb choices.
All the questions needn't be answered is an acceptable informal way to express the concept that someone does not need to answer all of the questions.
All the questions are not needed to be answered, on the other hand, violates two rules of formal written English: you must use the helper verb do not rather than are not in this context, and you must use bare need, not needed. Thus: All the questions do not need to be answered.
(All the questions need not be answered is also technically correct but nobody would write it that way today unless they were intentionally trying to sound old-fashioned.)
In both cases, I think the sentence also has a style problem: leading with All the questions is confusing, because "All the <noun> are not <predicate>" sounds ambiguous in English — do you mean "not all of the <noun> are <predicate>" or do you mean "none of the <noun> are <predicate>"? (Some people will loudly insist that it can only mean "not all ..." but that doesn't make it not sound ambiguous.) I would therefore write it differently:
informal: You needn't answer all the questions.
formal: You don't need to answer all the questions or Not all of the questions need to be answered.
(Even in prose that is so high-formal that you are supposed to actively avoid using contractions, I would still write don't, because in my head do not is reserved for the imperative. Your copyeditor may disagree, in which case listen to them, not me.)
All the questions needn't be answered
This one is possible informally, but not super likely because typically in Modern English negatives are done using "do-support".
All the questions don't need to be answered
In this case, it indicates that not every question requires an answer (implying that some questions may be left unanswered)
All the questions are not needed to be answered
This phrasing is uncommon, but not impossible.
In this case, the meaning of the two is approximately the same.
First, the second one is not grammatically correct in English. One cannot say "are not" in this situation; it should be "do not". I have corrected it below and removed the -ed suffix from the verb "need" to correct it further:
"All the questions needn't be answered."
"All the questions do not need to be answered."
Your first one is very formal as you're using "need" as a "modal". In Modern English, it is rare to hear or even see someone use "need" as a modal, especially these days. The most common phrase I hear these days wherein "need" is normally used as a modal is in the examples below:
"He needn't worry. I'll take care of it all."
"You needn't worry as long as you have me."
"Need I say more?"
"He need only tell the truth and nothing more."
"You need only do what you're supposed to; I'll take care of the rest."
There are other normal verbs that are sometimes used as modals in English, but many of them of phrasal modals; there is one main one, however, that isn't a phrasal one, which is "dare". The other ones that have semi-modal status like "dare" are "ought (to)", "used to", "had better", "have to", "had to". There are others as well; however, I am not going to list all of them, even though they are used often, because to do so is unnecessary:
"How dare he talk back to me? Who does he think he is?"
"Sir Charles, you dare resist?"
"I dare not say."
"John had me so upset that he dared not breathe a word to me!
In other words, both are correct, but your first one that uses "need" as a modal is more formal; however, that doesn't make the second one informal in this case. These are just two different ways to say the same thing and the second one is the regular way whereas the first one is really formal to the extent that I should dare call it "fancy-schmancy English"!