Is this sentence grammatically correct. I am particularly concerned about the why part:
As mentioned earlier, the goal is not always 100% clear but it is important to know 'the why' of wanting it.
English Language Learners Stack Exchange is a question and answer site for speakers of other languages learning English. It only takes a minute to sign up.Sign up to join this community
It is correct, and it's a construction that is used frequently. The scare quotes are not strictly necessary in this sentence, but they are not infrequently used, either. You will even find occasional use of double-quotes.
Saying the why or the what or the where is an idiomatic way of suggesting the type of questioning needed. You can think of the why as being roughly synonymous with "the answers to why questions", and as you can see below, if you want to add a subject afterwards, you use the preposition "of":
The BBC's Show The Why Factor
And here is a particularly fun one that's a little hard to decode:
US News & World Report: Revisiting the Why of Watergate
The NIH study Weight isn't selling: The insidious effects of weight stigmatization in retail settings: "Second, we examine the "why" of weight-based stigmatization and find that weight-related negative stereotypes compound to produce indirect but strong effects of stigmatization in retail settings (Study 2)"