Per the 4th amendment to the US Constitution, the FBI needed a warrant from a judge to search Mar a Lago.
Amendment IV
“The right of the people to be secure in their persons, houses, papers, and effects, against unreasonable searches and seizures, shall not be violated, and no warrants shall issue, but upon probable cause, supported by oath or affirmation, and particularly describing the place to be searched, and the persons or things to be seized.”
The affidavit is the statement explaining to the judge why the FBI believed searching Mar a Lago was necessary. “We believe documents are held at Mar a Lago in violation of US law. Our evidence of this is [insert evidence here].”
The judge accepted the reasoning and issued a warrant. The FBI went to Mar a Lago and removed government documents which Trump and his people had taken on their way out of Washington.
Trump, among his ever-changing excuses and claims around the situation, says the search was illegal/unnecessary/whatever and is demanding the affidavit be made public. The DOJ has objected. His lawyers would get the affidavit if he is indicted for crimes, but he, as he does, is waging a public-relations war.
The judge is allowing the release, but the affidavit will be heavily redacted (edited) to protect the FBI’s sources and methods.