Word-by-word translation does not always work, especially when faced with idioms. Usage indeed favours "dans le but de" over "avec le but de".
Why is it constructed this way? I have no idea and cannot find the origin.
Something about your Ngram is interesting though: the expression began to really be used in the XIXth Century. We may relate this to sports.
The « but » is the goal in sports too. The first example to come to mind is soccer, where it is the cage you have to put your ball into. Reading the history of soccer on Wikipédia, it seems to have known a great development in England around 1820-1830. France is not so far and may have taken example. Maybe there is connection, but this is speculation.
Sometimes, you just need to admit cultural differences change the way idioms are constructed and not overthink it.