David Venables denies murdering wife Brenda, 48, who disappeared in 1982.
In July 2019, her remains were found in a septic tank at what had been their shared home in Kempsey, Worcestershire.
Opening the case, prosecutor Michael Burrows QC said Mr Venables, now aged 89, had been in a relationship with his mother's former carer.
The Crown alleges Mr Venables, then 49, killed his wife and dumped her body in the septic tank in the grounds of remote Quaking House Farm, off Bestmans Lane, where the couple had lived since 1961.
Mr Burrows said: "He wanted her out of the way; he wanted to resume his long-standing affair with another woman.
"He knew about the septic tank in its secluded location.
"It was for him almost the perfect hiding place.
"And for nearly 40 years, it was the perfect place and he got away with murder."
The jury heard Mr Venables' affair with carer Lorraine Styles started around 1967 and continued on and off.
They had rekindled the relationship in the months before Mrs Venables vanished, Mr Burrows added.
He said Mr Venables had reported his wife missing at Worcester police station on 4 May 1982 and told officers his wife, who had been depressed, had not been in the house when he woke that morning.
A police investigation failed to find any trace of Mrs Venables, he added, and "some people thought" she had died by suicide.
By 2019, Mr Venables had sold the farm to his nephew and in July that year contractors clearing out the septic tank found bones, including a human skull, which DNA testing found were the remains of Mrs Venables.
Mr Burrows said it was "beyond belief" to suppose she had taken her own life by climbing into the septic tank.
The trial of Mr Venables, of Elgar Drive, Kempsey, continues.