In a nutshell, the rule is to apply to the main destination and, if there is no main destination, to the first country you will visit in the Schengen area. Based on your description, I don't think there is a clear “main destination” to your trip so I would apply to the country through which you will enter the Schengen area, namely Italy. But it's also possible to regard Greece as the main destination because of the time spent in the islands.
What happens if you apply to the wrong embassy/consulate is that they should decline to process your visa application as per article 18 of the Schengen Visa code:
Verification of consular competence
When an application has been lodged, the consulate shall verify whether it is competent to examine and decide on it in accordance with the provisions of Articles 5 and 6.
If the consulate is not competent, it shall, without delay, return the application form and any documents submitted by the applicant, reimburse the visa fee, and indicate which consulate is competent.
(Article 5 is the one defining the rules I described at the beginning of my answer.)
In particular, it's not a “refusal” (article 32), it does not count as a negative decision or precedent and you should even get your documents and money back (which is not the case for a refusal) so you have lost nothing except the time it takes to wait for the consulate to get back to you and reapply somewhere else.