The dispute is about the place of worship and not about the place of a hospital or place for any other subject.
The court referenced a report from the Archaeological Survey of India (ASI) as evidence suggesting the presence of a structure beneath the demolished Babri Masjid, that was found to be non-Islamic.
In 1950, the state took control of the mosque under section 145 CrPC and allowed Hindus, not Muslims, to perform their worship at the site.
Two archaeological excavations in 1978 and 2003 conducted by the Archaeological Survey of India (ASI) found evidence indicating that the Hindu temple's remains existed on the site.
Over the years, various title and legal disputes took place, such as the passage of the Acquisition of Certain Area at Ayodhya Act in 1993. In 2010, the Allahabad High Court ruled that the 2.77 acres (1.12 ha) of disputed land be divided into 3 parts, with 1⁄3 going to the Ram Lalla or Infant Lord Rama represented by the Hindu Mahasabha for the construction of the Ram temple, 1⁄3 going to the Muslim Sunni Waqf Board and the remaining 1⁄3 going to a Hindu religious denomination Nirmohi Akhara.
When the Allahabad high court decided to partition the property into three parts and to allot one such share to Muslim Sunni Wakf board, was there any claim made by The Allah the Great directly to the court or whether the court accepted the consent parties as representatives of Allah The Great.
A detailed explanation about the origin of title has been given in the verdict which includes various arguments for and agaisnt by eminent lawyers and great personalities appeared before the apex court.
Therefore you can find the answers for all your queries if time permits your to peruse the SC verdict on the subject.