Why Julius Caesar and Cleopatra had a child?

It is because Cleopatra was trying to make herself queen of Egypt by getting help from Caesar. Caesar did not know if he should trust her. With the birth of their child Caesar knew that Cleopatra was trustworthy enough and thus ready to become a queen.