I'm Italian and I visited Rome as a tourist myself about one year ago.
The image which mouviciel so usefully linked is self-explanatory, but it is not true for Rome or Vatican City only, all the churches in Italy have something similar being displayed IF they are regularly visited by tourists (otherwise, the same rule holds but there is no specific warning, as the people who go there would know).
Men can surely enter a church wearing a pair of knee-length, loose pants (no need to be wearing long trousers), but sleeveless tops or T-shirts, tight sports shorts and similar items are not accepted. The same is true for women, who should not be wearing mini skirts, short pants or sleeveless tops. I forgot to say that low necklines or thigh slits in skirts would not be accepted either, nor would it be accepted to have part of your underwear showing, as is frequently the case with young people who wear their jeans very low at the back.
Italy is a Catholic country where until recent times women would cover their heads when in church, whereas men had to remove their headcovers and go bareheaded. It's a matter of decorum which still holds. It might sound out of place, but it is not much different from having to remove your shoes when visiting Asian temples and mosques (where a dressing code is also implemented and where women have to cover their heads).