The myth that the Muslim Saint Mian Mir laid the foundation stone of Darbar Sahib is first mentioned in “Tawarikh-i-Punjab” written by Maulvi Butay Shah, a Muslim and former Mughal historian, in 1848. The myth is not found anywhere in Pre-colonial literature.
Traditional Sikh literature, tells us that Guru Arjan Dev himself laid the foundation stone. For example, in the work of Santokh Singh a Nirmala. Rattan Singh Bhangu a notable Sikh writer, as he wrote the Prachin Panth Prakash, read through Maulvi Butay Shah's account and found it was filled with fabrications including the story of Mian Mir. Multiple Sikh intellectuals wrote against this lie in the 1800s.
However, this lie has become entrenched in most Sikhs' minds, because it fits into the modern Sikh's understanding of Sikhi. Maulvi Butay Shah doesn't even provide any sources and its work contradicts 200 years of history that predates him.
Maulvi Butay Shah was a Mughal historian hired by the British to write about the history of Punjab after the First Anglo Sikh War. He was charged with writing an accurate and unbiased version of Punjab's history. However, he used this opportunity to whitewash Islam and the Mughal Empire's crimes against Sikhs. One way he did this is by saying Mian Mir layer the foundation stone of Darbar Sahib. This was done to give Islam a better image and it also infantilizes Sikhi as it shows that it relied on a Muslim holy man to sanctify Darbar sahib, thereby showing Islam is the superior religion. Even the British officers who hired him noticed that he didn't listen to instructions and was not unbiased.
However, Mian Mir and Guru Arjan were very good friends as were Mian Mir and Guru Ram Dass.