Without getting into the nitty-gritty chapter and verse, here is a sketch of the logic. Incidentally, since the indictment of Donald Trump today was in a New York State court, that indictment is governed by the New York State rules of criminal procedures which do not closely track the federal rules of criminal procedure. New York State is one of about half of U.S. states, mostly in the eastern U.S., which, in addition to the federal system, are required to initiate most serious criminal cases with a grand jury indictment, rather than merely a filing by the prosecutor without a grand jury.
Grand jury proceedings are secret. This is so that prosecutors can use grand juries to gather evidence in order to charge suspects with criminal charges in secrecy so that suspects in criminal investigations do not use knowledge that they could obtain from a grand jury investigation in order to thwart the investigation by fleeing or hiding from arrest, destroying evidence, tampering with witnesses, and/or coaching grand jury witnesses to give testimony that supports or contradicts the testimony given by previous witnesses.
In states like New York, a grand jury investigation is the primary way that prosecutors can compel people to provide testimony in a criminal investigation prior to charging someone with a crime. In states without a strong grand jury system, the prosecutor normally has subpoena power to compel witnesses to give testimony or information to a prosecutor without the involvement of a grand jury.
Frequently, and as a default, once a grand jury decides which charges the prosecutor is allowed to bring in an indictment by casting a majority vote in favor of each of the charges in the indictment (this is called a "true bill"), the prosecutor still wants to keep the facts related to who has been indicted for what secret.
The prosecutor wants to keep the indictment a secret in order to facilitate the arrest of the suspect or suspects, until a warrant for the arrest of the person can be carried out without the suspect knowing that it is coming, or until an arraignment, in the alternative, when the court formally asserts its jurisdiction over the defendant, takes a plea, and is in a position to set bail.
This way, a defendant won't flee because there are any charges against them (usually grand juries indictments are reserved for felonies or serious misdemeanors), or because the charges are more serious that the suspect believed that they would be.
Once the court has adequate assurances that the suspect won't flee, by having the suspect in court, submitted to its jurisdiction, either by virtue of an arrest or a voluntary appearance with pre-trial release conditions established, the court no longer has to worry about the suspect fleeing, and the indictment can be unsealed.
In a case like the one today, where Donald Trump is appearing voluntarily at an arraignment in a court appearance carefully coordinated with his secret service detail, the flight risk concern is smaller, but the procedures are set based upon the average case and not the exceptional one. Due to the highly newsworthy nature of this case, the existence of an indictment was announced in advance and there was leaks that have been largely disregarded as "harmless" about the contents of the indictment.
But, in the usual case, secrecy prior to an arrest or voluntary appearance at an arraignment is paramount as a matter of the operational effectiveness of arresting law enforcement officers, and the public doesn't even know that there is an indictment or even sometimes that there is a pending grand jury investigation, until the indictment is unsealed at an arraignment.