Allah Knew everything before it came into being and what’ll happen to it afterward.He then brought then into existence ,all in accordance to His perfect knowledge & measure.This belief doesn’t contradict the fact that one must strive to attain things.