Why Are They On Earth?
Again, it depends on which version of the franchise you're asking about. In every version other than the movie, they're here by accident; the original characters crashlanded here in prehistoric times, an origin that has stayed (almost) intact ever since. According to the movie, however, they're here intentionally, tracking down the cosmic McGuffin the All Spark, which ended up here after Optimus Prime tossed it into space to make sure that Megatron would never get his hands on it.

Why Do They Transform?
Because that's the entire point of the toy. Duh. If you're looking for an in-story reason, it's so that the robots can go about their business of Trying To Take Over The World/Trying To Save The World/Trying To Defeat Their Enemy (delete as applicable) without getting noticed too much. In some incarnations, after the robots crash-landed on Earth, they were given the ability to transform by their damaged spacecraft, looking out for their needs apart from that whole "crashing on Earth" thing; in the movie, the origin of the robots' ability seems to be as part of the side-effect of being brought to life by the All Spark, although that does raise the question of what the Transformers were before they were giant robots.

Advertisement

How Does A Transformer Get Born, Anyway?
In all versions of the franchise other than the movies and Transformers: Animated, the Transformers were created by a being known as Primus, who distilled his life-force into something called the Matrix, which is used to bring a Transformer into life. In movie continuity, the Matrix and Primus are replaced by the All Spark, a cube of unknown origin that can turn any object into a living, transforming robot.

Do The Transformers Have Gender?
Apparently so, as the existence of Arcee (and a surprising number of others) proves. Quite why alien robots have gender was left unaddressed until IDW's 2008 Transformers Spotlight: Arcee comic, wherein it was revealed that a Transformers called Jhiaxus, the "Chief Theoretical Strategist" of all Transformers tasked with remaking and improving their race, had introduced gender as part of his experimentation.