• 에 - postposition of location (determining destination) = to
• (으)로 - postposition of motion/direction (determining the direction of the movement) = toward
• 을/를 - postposition of "object" but also of "purpose" (contrasting object to subject and defining the object as the "objective")
For simplicity, let's consider the example in the affirmative.
학교에 가요 - I go to school (school = place of destination)
학교로 가요 - I go toward school ( = in the direction of the school. School, not necessarily be the final destination)
학교를 간다 - I attend school (~ go to get schooling. Emphasis is on the purpose of the school, and not on school as a location).
"학교를 가다" vs "학교를 다니다" .
With the use of the object marker -를, both verbs imply the purpose of the action i.e. to get schooling/to be schooled.
-를 가다 (= to go/attend to be schooled) puts more stress on the purpose of the action.
-를 다니다 [=to go regularly/to attend regularly (to be schooled)] puts the stress not only on the purpose of the action, but also on the regularity/routinal frequency of such action.
Both expressions are correct depending on context.