Louis XII invaded Italy in an attempt to get a foothold in the country. Italy at the time was not a united land and was made up of several city states. Louis first conquered Milan, before continuing forward into Florence and Rome.
Wishing to then conquer Naples, Louis allied and received help from the Spanish and divided the kingdom of Naples with the King of Spain. However, the agreement did not take long to fall apart. The next few years saw the Spanish fight against the French and successfully take Naples from the French King.
Ferdinand II said of Louis:
The King of France complains that I have twice deceived him. He lies, the fool; I have deceived him ten times and more.
Machiavelli believed that the attempt to take the Kingdom of Naples was a mistake by Louis XII. If France could have attacked Naples with their own force then they should have done so, but if that was not possible then they should not have divided the kingdom. Louis should not have conquered lands that could not be kept.