Why did so many South American countries legalize homosexuality in the 1800s? Did it have something to do with decolonization?
I can answer for my country, not sure if this will be removed because it won't answer your question totally but maybe it'll give some perspective (mods let me know if this breaks any rules and i'll remove it). Uruguay's constitution in 1830 states that (doing my best to translate here) "Any man's private actions, that don't constitue an attack or disruption of public order and don't harm others will only be reserved to God and therefore exempt from the authority of judges". The part referring to God was left out in the constitution of 1918 because of the separation between church and State. While the crime of "Sodomy" existed until 1934 it was listed under the crimes of rape and was only investigated if someone ("the offended") requested inquiry or was publicly noted as violent and or caused someone's death.
Source: "Homosexualidad, la visión social" by historian José Pedro Barrán. Published in revista relaciones 2005. Spanish Link
My interpretation of what Barran writes and quotes from the criminal code of 1889 is that while homosexuality was in fact criminalized it was very rarely pursued as a criminal act on its own (when sex was consensual and between 15+ aged individuals). That being said, there's no denying that it was frowned upon socially and cultural condemnation of homosexuality persisted well into the twentieth century.
As a side question, what started the illegalization of homosexuality in South America before this period in the 1800s? Was it a direct result of European colonization, or was there more at play?
Does anyone know whether anti-clericalism in Latin America during this time period played into the legalization of homosexuality?