This known as the fate of the unlearned. It exists in two forms: for people living before the revelation, and for people living after the revelation but isolated from it. Many different answers exist depending on religions, schisms and people within these religions. You can however see "categories" of answers, regardless of the details of each doctrine. For Islam (and most religions), the answers can be summed up by:
there are no unlearned, since god supplied a sufficient amount of prophets, or made enough people spread the faith. This applies only to current unlearned.
some unlearned go to heaven, but it would have helped if they learned
they burn in hell forever (which may not be the first thing to mention when trying to teach them)
they are judged on their actions independently from their faith (which can be problematic, since it gives no incentive to believe)
Apparently, there is no consensus on this within Islam.
- "we know that the future is already written" is a little vague. It does not specify if you are speaking about a fully deterministic world, or a broader future written event (like some final apocalypse that will happen whatever you do)
This is a problem that is not inherent to Islam. In a purely deterministic world, there would be no free will. Our thoughts would be triggered by one another, by our environment, by some other spiritual influence... Even with less determinism, the idea that we are largely (or entirely) the product of external forces (divine or not) is quite challenging to the concept of person as we know it.
In pratice, not many people seriously consider this idea since it removes responsibility. Furthermore, even if it were true, it would still be completely unpractical (your brain is too complex, we are absolutely unable to predict what your next thought will be). So we might just consider some kind of free will regardless of its validity, at least for our justice systems which are based on it.