The REPLACE function in MySQL takes three inputs: the original string, the substring to find, and the substring to replace it with. It searches the original string for all occurrences of the search substring. If found, it replaces each occurrence with the new substring. If the search substring is not found, it returns the original string unchanged. For example, replacing 'world' with 'MySQL' in 'hello world' results in 'hello MySQL'. This process continues until no more occurrences are found. REPLACE always replaces all occurrences, not just the first one.