In order to plead guilty, a defendant must enter the plea voluntarily and intelligently. In addition, for a judge to accept a guilty plea, there must usually be a factual basis for it. To some courts, the factual-basis determination is part of the inquiry into whether the plea is voluntary and intelligent.
In federal court and in most state courts, a judge must confirm that there is a factual basis for a guilty plea. (But see Must there be a factual basis for a "no contest" plea?) In other words, the judge must determine whether there is evidence that the defendant actually committed the crime in question. Some states frame the issue like this: Can the judge “say with confidence” that the prosecution could prove the defendant guilty? (Turner v. State, 961 So. 2d 734 (Miss. Ct. App. 2007).)
The requirement that there be facts to support a guilty plea is based in no small part on the fear that defendants may sometimes enter pleas due to their mistaken beliefs about guilt. (But see Pleading Guilty While Saying You’re Innocent and Can defendants plead guilty to different crimes than those they committed?)
Example: Stephanie, who is mentally challenged, was charged with child sexual assault based on her having had intercourse with a 14-year-old boy. In the probable cause portion of the criminal complaint, a police officer wrote that Stephanie claimed that the boy raped her. The officer also transcribed the alleged victim’s account of events, which allowed for the possibility that Stephanie didn’t consent to the sex in question. At the preliminary hearing, the boy confirmed that he was the one to initiate sex. The judge accepted Stephanie’s guilty plea, finding that the complaint and preliminary hearing established a factual basis for it. But the judge never asked Stephanie about her claim that the boy raped her, and never established that she knew that she couldn’t be guilty if it was rape. Finding that the judge should have asked more questions to determine whether Stephanie actually committed the crime, the appeals court sends the case back for a hearing on whether her plea was knowing and intelligent. (State v. Lackershire, 301 Wis. 2d 418 (2009).)