Humidity inside the lens – now what?

Recently, I found an old portrait of my wife, Monika, taken on a sunny beach in Portugal. During the shoot, I faced a challenge: my lens was foggy and the autofocus failed. Fearing my expensive lens was ruined, I placed it in the sun to dry, and miraculously, it worked! How did humidity get into my lens?