That is a very frequently asked question :)
Until the gender of the noun is revealed, you use 'det'. For example:
A: Det er en bog
B: Den er god
B uses 'den' because A established the gender of the noun and can therefore use the article 'den' to refer to 'bogen'