This question already has an answer here:
God knows everything like present , future and past than why did they not vanish the demons as they take birth. These demons upset the earth by their act like killing , raping , corruption etc.
From my point of view If any person doing any wrongful act than he/she should die immediately. Than why god do not give punishment at the same time when any thing become wrong