Under the Ostrogoths, Lombards, and Carolingans, the Kingdom of Italy was a pretty run-of-the mill medieval polity apart from it's dense urbanization.
After the wars of succession following Emperor Charlemagne's death, the Kingdom of Italy was given to Lothair (a grandson of Charlemagne's) in 795. The uneasy but relatively stable transitions between the various Carolingans sharing French, Italian and German crowns in all a manner of combinations ended in 887, after the deposition of Charles the Fat, who was last holder of all three crowns. The fight between innumerable female-line descendants for the title of King of Italy was on, foremost of which was Berengar, Marquis of Friuli, and Guy, Duke of Spoleto. No pretender to the crown was able to assert himself, while an incursion by Arnulf, King of France and Germany (but obviously not Italy) in 894 didn't help the situation.
After the resources of the Italian lords were spent, the Kings of Burgundy and Provence contested the title until Berengar, Marquis of Ivrea and grandson of the deposed Berengar of Friuli, machinated the support of Emperor Otto and was crowned crowned King Berengar II. However, Otto soon decided to take the crown for himself.
The Ottonian Emperors (Otto I, Otto II, Otto III, and Henry II) would all travel to Italy to be crowned King of Italy by an Italian Bishop (whether it was the Bishop of Rome or Milan was of little consequence at this point).
Here the histories of Western Europe diverge. As already stated in the excellent answer here; After the collapse of the Carolingian Empire, the French nobility elected Hugh Capet, a great magnate in the Île-de-France, to be king in 987. This election saw the beginning of the Capetian line of kings. However, at the beginning, the Capetians had no real power outside of the Île. They were largely figureheads. This began to slowly change, beginning with Louis VI (reigned 1108-1137) who began to move to solidify royal power in the rest of his kingdom. This process was accelerated by Philip II (1180-1223), who reclaimed Normandy from the English kings and otherwise massively expanded the royal demesne.
These expansions led to the implementation of a stronger bureaucracy, as the kings now needed to send representatives in order to carry out basic functions of government like the collection of taxes. Since the seat of power for the Capetians was still in Paris, this meant that France eventually became very centralized, with Paris as the focus.
Now in Germany, things started out similarly. Henry I, the Fowler, was elected king in 919, and he went on to found the Ottonian dynasty. The Ottonians had their power consolidated mostly in Saxony, which was actually larger than the Île-de-France.
However, Otto II (the third king in the dynasty) died suddenly, and the rule of Otto III was less stable because of this. Otto III died young and without heirs, and the next king was a cousin from Bavaria, Henry II, also childless. A new election was held, and Conrad I was elected king, marking the beginning of the Salian dynasty, originally based in Franconia. These dynastic shifts continued throughout the Middle Ages, moving the center of power around Germany as they happened. Because Germany was less centralized, a centralized government did not form. Instead, the kings ruled by traveling, a form of kingship known as peripatetic kingship (in English sometimes called the Royal Progress). Although they had bureaucrats just like the French, they didn't all centralize into one location. Instead, the king went to where the problems were, and his bureaucrats came with him. This meant that no centralized institutions of power, like the exchequer in England for example, developed. It also meant that more power was retained locally by the local lords.
On top of this, the fact that the king had to keep being re-elected meant that the king couldn't necessarily alienate the other great magnates in Germany. All of this led to less centralization in Germany than in France.
Now let's take a step back. The Ottinians were elected in Germany. However, they had seized Italy by conquest, annihilating the feudal landholders. How did they then rule Italy? The Ottonian system utilized episcopal investiture (appointing Bishops, in Italy centered on large urban centers) as a way of delegating authority without having to go through the lord in a region. (N.B: Quoted and paraphrased text in hyperlink)
All this confirmed the Italian Post-Roman cities as centers of religious and political life. In Milan, for example, the landed families of Della Torre, Argentea, Baggio, Busto, Grassi and Caronia, along with many other smaller ones, all converged onto the Bishop of Milan asking for privileges in the marketplace, arbitration of disputes and in a general sense all the functions that would normally be rendered by the Obertenghi, who were their feudal overlords on paper, but whom the Ottonians saw to make rapidly irrelevant beyond their castle in Este. Throw in the aforementioned decentralization of the Holy Roman Empire, and the Italian cities didn't take long to become the dominant political entities in Italy.
In many Italian cities, the convergence of so many locally wealthy and powerful individuals along with an "Artisan" class that could only exist thanks to the density of urbanization, led many cities to adopt a unique, vaguely democratic system of government. Although the system changed from city to city, most established a legislative council of leading families headed by the local Bishop. Often, the leaders of local artisans of merchants guilds were also allowed to participate. Many cities elected a Podestà, who was often by law required to be a citizen of a different city, to act as a neutral arbiter during these meetings; the mere fact that this could happen attests to the thick web of relations in urban communities in Italy.
Thus, by the Year 1002 the cities of Crema, Cremona, Milan, Monza, Bergamo and Brescia were all thriving "Communal Republics" while the House of Obertenghi, who should of ruled over them, was all but unknown! Along with the Podestà, the most important job in the communes was that of Capitano del Popolo, or Captain of the People. He acted as a Commander-in-Chief when the city was threatened with war by a rival city, and commanded the cities' forces should they decide to conquer a neighboring city. Milan, Verona, Florence, and to a lesser extent, Padua, gained a reputation as "Bully" cities in northern Italy, expanding their territory far beyond their outskirts.
Between the 13th and 15th centuries, the Milanese, Paduans, Veronese and Florentines were almost continuously involved in some kind low-level warfare, often bullying smaller surrounding towns into submitting in order to establish a ring of fortified burghs around their capital.
Starting from the mid 13th all the way up to the early 15th century, there was a trend for one family to dominate the others, and either pay lip service to the communal institutions while really ruling alone (like the Carrara in Padua, the Dovara in Cremona, and famously, the Medici in Florence) or outright dismantle them, often via bloody internal struggle against opposing families (like the Visconti in Milan, the Scaligeri in Verona, and the Ezzellini in Treviso and Vicenza).
So how is it possible that Italy goes from a hodgepodge of mostly republican city-states in the thirteenth century to the half-dozen or so mostly absolutist Italian States of the 15th century?
In part, centralization of the ossified Italian states on the person of a single monarch (the Savoyards in Savoy, Piedmont and Monferrato, the Visconti in Milan, the Este in Ferrara and the Medici in Florence) was an unavoidable trend manifested in all early modern Europe, as was the subjugation of weaker, and perhaps more republican, states by the "Bullies" (Pisa and Siena by the Florentines, the small lordships of Romagna by the Pope, and nearly all of northeastern Italy by Venice) of Romagna.
More exceptional, in fact, is the preservation through to the Early Modern Era of two republics, Genoa and Venice.
Genoa, after it's zenith in the twelfth and thirteenth centuries, would first become a puppet of the Milanese, and later be reduced to be client-state of Spain. The Venetians, on the other hand, are a more complex story, which I will link to since they could warrant a post on their own.
Books on the Communal System in Italy:
The Lombard League by Gianluca Raccagni (Oxford University Press, 2010)
History of Lombards by Jorg Jarnut (Enaudi, Torino, 2002)
and if you'd like a proper textbook:
The Italian City Republics, by Daniel Philip Waley (Routledge, New York, 2010)
To read about Venice, which is an example of the Italian communal system taken to the nth degree, read A History of Venice by John Julius Norwich
In Italy, the Emperor was far away and day to day politics in the 11th-12th century were delegated to the feudal class. That was the military aristocracy in the rural areas, and the bishops in the cities.
BUT, while the military aristocracy was hereditary, bishops were elected - usually by the priests belonging to the local Cathedral. And the priests of the Cathedral were invariably members of the powerful local families. This created a situation where powerful local families were involved in managing the power within the borders of a city.
At the same time, the concentration of professionals in cities gave rise to guilds, brotherhoods and lobbies set up by commoners, and these too were involved in the politics by the families. In time, this created a fertile ground for the emergence of a republican government.
This of course was a concern for the central power. But while Norman kings in southern Italy were quite successful in quenching this trend early, the Emperors could not, and when they tried to impose their own Bishops, removing the election system, citizens rebelled and exiled them, electing their own Bishops. In time, the Bishop institution, which had become a mask anyway, declined and power formally passed in the hands of Councils and Consuls.