How can Hashem set up witnesses before Yisrael have sinned?
Rashi: He set them up as witnesses that He had warned Yisrael, not to testify that they had sinned. 1
Rashbam: This was an advance warning that the Heaven and earth will come and punish them in the event that they sin. 2
How can Heaven and earth testify whether Yisrael fulfilled the Torah? The testimony affects them
Refer to 4:26:1:1.
Moshav Zekenim: Indeed, they are not believed to testify that Yisrael fulfilled Torah, but they would be believed to testify that they transgressed Torah, for this harms themselves. 1
Testimony that harms the witness himself is accepted. It is unlike a relative, whose testimony is Pasul whether it helps or harms his relative (Shach CM 37:1 derives this from Rema 37:17).