Jennifer Lopez was offered the role of the female lead, but turned it down. The character was played by Eva Mendes instead.
According to Will Smith, the plan was originally for Cameron Diaz to play the female lead. Smith says that much of the reason the role went to Eva Mendes instead was because studio executives were uncertain audiences would be comfortable with the main romance being between a black man and white woman! However, studios also didn't want to have both leads be African American as they feared this would alienate non-black viewers. Therefore, according to Smith, they were adamant they wanted the character to played by a Hispanic.
It was Will Smith who convinced the studio to cast Kevin James as Albert. Will Smith was a huge fan of James's hit TV show KING OF QUEENS.