Gender in Danish is a grammatical feature of words. It's not based on any criterion that makes sense, as in English, it's just something you have to learn.
PS: While gender works differently in Danish, this sentence isn't actually an example of the difference. Consider "THAT is a girl".
Any sentence like "it is a [noun]" should be translated as "det er en/et [noun]"
In the construction "it is [adjective]" the use of den/det depends on the genus of the noun that is referred to e.g.:
The tire is flat = dækket er flat; it is flat = det er flat
The boat is sinking = båden synker; it is sinking = den synker
"Den er en pige" should only be used when referring to animals. You would never say about a human "Den er en pige", as "den" only should be used when talking about animals or objects.
Examples: Den er blå = It is blue Den er nuttet = It is cute Den elsker at lege = It loves to play
"Det er en pige" could be talking about both an animal or a human, if asked about what gender the human or animal is. For example if someone had just given birth, the new mother would be told "Det er en pige" (or "det er en dreng").
If someone asks you what gender your dog is, you could reply with "Det er en pige" or "den er en pige"
A: Det er en sød hund. Er det en pige eller en dreng? (That is a cute dog. Is it a boy or a girl?)
B: Det er en pige (It is a girl)
A: Min kone har lige født (My wife has just given birth)
B: En dreng eller en pige? (A boy or a girl?)
A: Det er en pige (It is a girl)
(In the first example you could also have used "den" instead of "det")
Just some examples on when you use the sentence "det er en pige"